comp.lang.ada
 help / color / mirror / Atom feed
* pragma Pack vs. Convention C, portability issue?
@ 2008-01-09  8:40 okellogg
  2008-01-09 16:06 ` Adam Beneschan
  2008-01-11  4:20 ` Randy Brukardt
  0 siblings, 2 replies; 13+ messages in thread
From: okellogg @ 2008-01-09  8:40 UTC (permalink / raw)


-- File: main.adb
-- Can we portably rely on pragma Pack taking precedence
-- over Convention C?
with Text_IO;

procedure Main is

   type C_Represented_Enum is (Zero, One, Two, Three);
   pragma Convention (C, C_Represented_Enum);
   -- This would be 32 bits on a 32 bit architecture

   type Perhaps_Packed is array (1 .. 4) of C_Represented_Enum;
   pragma Pack (Perhaps_Packed);
   -- This could be either 8 bits if the compiler lets pragma Pack
   -- take precedence over Convention C, or 4 * 32 = 128 bits
   -- otherwise.

begin
   Text_IO.Put_Line
     ("Perhaps_Packed'Size is" &
      Natural'Image (Perhaps_Packed'Size));
end Main;



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-01-12  4:58 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-09  8:40 pragma Pack vs. Convention C, portability issue? okellogg
2008-01-09 16:06 ` Adam Beneschan
2008-01-09 22:12   ` Robert A Duff
2008-01-11  4:15     ` Randy Brukardt
2008-01-11  4:15     ` Randy Brukardt
2008-01-11  4:15     ` Randy Brukardt
2008-01-11 19:17       ` Randy Brukardt
2008-01-10  5:53   ` okellogg
2008-01-11  4:20 ` Randy Brukardt
2008-01-11 19:53   ` (see below)
2008-01-12  0:35     ` Adam Beneschan
2008-01-12  4:58     ` Randy Brukardt
2008-01-11 22:46   ` Robert A Duff

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