comp.lang.ada
 help / color / mirror / Atom feed
From: okellogg <okellogg@freenet.de>
Subject: pragma Pack vs. Convention C, portability issue?
Date: Wed, 9 Jan 2008 00:40:50 -0800 (PST)
Date: 2008-01-09T00:40:50-08:00	[thread overview]
Message-ID: <a244cc70-8735-468d-a0ad-b2b659b6d58e@v67g2000hse.googlegroups.com> (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;



             reply	other threads:[~2008-01-09  8:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-09  8:40 okellogg [this message]
2008-01-09 16:06 ` pragma Pack vs. Convention C, portability issue? 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
replies disabled

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