[lug] More packing troubles...

Tkil tkil at scrye.com
Mon Jun 11 20:33:32 MDT 2001


>>>>> "David" == David Trowbridge <jupiter at flatirons.org> writes:

David> I just now ran into the same problem with porting a network app and
David> #pragma pack. My problem is this: in the app, before a network command
David> structure, there are these two lines:
David> #pragma pack (push, pre_spi)
David> #pragma pack (2)
David> and ending with this after the struct:
David> #pragma pack (pop, pre_spi)

from the discussion at

   http://gcc.gnu.org/ml/gcc-patches/2000-09/msg01150.html

it looks like it should be:

   #pragma pack(push [, id], alignment)
   ...
   #pragma pack(pop [, id])

but my build doesn't like that either.  the only version my gcc seemed
to accept was:

   #pragma pack(1)
   ...
   #pragma pack()

(where the empty pragma switches back to the previous / default
packing.)  version:

| $ gcc -v
| Reading specs from
| /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
| gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
| $ rpm -qa | grep egcs
| egcs-1.1.2-12

David> I've defined HAVE_PRAGMA_PACK_PUSH_POP to 1, 

as i pointed out in a previous e-mail on this topic, these flags only
matter when you are building gcc itself.  they shouldn't have any
effect on other programs.

David> Just like the original poster, I'm desperate to avoid the gcc
David> lists.

well, you'd probably get gently nudged off the main gcc list, since
that's designed for developers of gcc, not really for users.  there
are some newsgroups that might be useful.  also, the lack of
documentation for this pragma really sucks; that should perhaps get
filed as a bug.  (of course, with 3.0 due out this friday, the gcc
developers are just a wee bit frantic...)

David> All I need is a pointer to where to look for documentation on
David> this.

a recent development version indicates that the formats should be:

   /* HANDLE_SYSV_PRAGMA */
   #pragma pack(<n>)
   ...
   #pragma pack(0)

or

   /* HANDLE_PRAGMA_PACK_PUSH_POP */
   #pragma pack(push, <n>)
   ...
   #pragma pack(pop)

on my egcs install, however, that doesn't work.  i shouldn't be too
surprised; it looks like the big changes were the cpp rewrite and the
tweaks for this pragma, and those were both late 2000 -- egcs-1.1.2 is
getting rather long in the tooth...

hth,
t.



More information about the LUG mailing list