Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: CHAR_BIT != 8

by tobyink (Canon)
on Mar 08, 2013 at 15:45 UTC ( [id://1022450]=note: print w/replies, xml ) Need Help??


in reply to CHAR_BIT != 8

C99 says that CHAR_BIT must be at least 8; POSIX says it must be exactly 8; on Windows it's 8. That's about all the platforms it's worth caring about.

Some DSPs use CHAR_BIT=16 or CHAR_BIT=32, but they're never going to run Perl anyway.

How to get it? This is cheating I'm sure...

use strict; use warnings; my $char_bit; open my $fh, "<", "/usr/include/limits.h"; while (<$fh>) { ($char_bit = $1, last) if /^#\s*define\s*CHAR_BIT\s*([0-9]+)/; } print "$char_bit\n";

It's the kind of detail you might expect to be provided by Config, but no such luck :-(

Update: meh... I wasn't looking hard enough...

use strict; use warnings; use Config; print "$Config{charbits}\n";
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Replies are listed 'Best First'.
Re^2: CHAR_BIT != 8
by ribasushi (Pilgrim) on Mar 08, 2013 at 16:13 UTC
    Oh indeed. New Config piece starting from 5.12, this is why I didn't see it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1022450]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-23 16:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found