comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@gnat.com (Robert Dewar)
Subject: Re: pragma pack in external packages
Date: 25 Apr 2002 18:52:06 -0700
Date: 2002-04-26T01:52:06+00:00	[thread overview]
Message-ID: <5ee5b646.0204251752.1aa1bccb@posting.google.com> (raw)
In-Reply-To: db500a4f.0204250849.61c0791e@posting.google.com

robert_s_quinn@yahoo.com (Robert Quinn) wrote in message news:<db500a4f.0204250849.61c0791e@posting.google.com>...
> Suppose I have an array of bits:
> 
>    package definitions is
> 
>       ONE_BIT_TYPE is range 0..1;
>       for ONE_BIT_TYPE'SIZE use 1
> 
>       5_BIT_ARRAY_TYPE is array (1..5) of ONE_BIT;
>       pragma pack (5_BIT_ARRAY_TYPE);
> 
>    end definitions;
> 
> It seems like my 5 bit array should now refer to 5 
> consecutive bits.
> But now if I try to use this array in a record in an
> external package,
> I get an error:
> 
>    package more_definitions is
> 
>       type my_record is record
>          IMPORTANT_5_BIT_ARRAY :            
                 definitions.5_BIT_ARRAY_TYPE;
>       end record
>       
>       pragma pack(my_record);
>       
>       for my_record use record
>          IMPORTANT_5_BIT_ARRAY at 0 range 0 .. 4;
>       end record;
> 
>    end more_definitions;
> 
> after compile I get:
> ERROR: size for IMPORTANT_5_BIT_ARRAY too small, minimum 
> allowed is 40

I am willing to bet you do NOT get this message if you compile the
above code, which probably comes close to the
record, even on CLA, for junk syntax errors per line. Among
the errors are:

missing type keywords
identifiers starting with digits
undefined identifiers
missing semicolons

Any reasonable correction of this mess will compile just
fine. It is really important to post *EXACTLY* the code
you tried, not some distressingly inaccurate memory of it!





> 
> Note that I don't get this error if I move the record declaration
> INTERNAL to the package where the array type is defined.  Only when I
> use the array type in an external package does the compiler decide I
> need a whole BYTE for each BIT of data!
> 
> Any ideas?
> Thanks,
> Robert Quinn
> 
> Note that I don't do any low-level programming in my job (is this what
> you low level programmers do a lot of?), this is just a hobby.



      parent reply	other threads:[~2002-04-26  1:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-25 16:49 pragma pack in external packages Robert Quinn
2002-04-25 19:03 ` Stephen Leake
2002-04-25 19:07 ` Pat Rogers
2002-04-26  1:55   ` Robert Dewar
2002-04-26  1:52 ` Robert Dewar [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox