This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: #pragma push breaks bootstrap?


Hi Robert,


Just to clarify, there are two kinds of #pragma pack:

The SystemV kind which look like:

	#pragma pack(<n>)

and which sets structure packing to <n> bytes until overriden by
another occurance of #pragma pack (<n>) or an occurance of #pragma
pack() which turns off structure packing.

The Microsoft extensions to the syntax which look like:

	#pragma pack (push, <n>)

which does the same thing as #pragma pack(<n>), except that it can
later be undo by:

	#pragma pack (pop)

which resets the packing back to the previous level.
	

: > 	a. #pragma pack is being used by your system header files
: 
: Yes.
: 
: I can send you samples if you like, but they essentially look something
: like:
: 
: #ifndef _STDIO_H
: #define _STDIO_H
: 
: #pragma comment(exestr, "xpg4plus @(#) stdio.h 20.2 95/12/11 ")
: 
: #pragma pack(4)
: 
: #ifdef __cplusplus
: extern "C" {
: #endif
: 
: [ meat of header munched ] 
: 
: #pragma pack()
: 
: #endif /* _STDIO_H */
: #endif

Ahh, this is starting to make a lot more sense now.  My guess is that
the i386 toolchain does not define HANDLE_SYSV_PRAGMA, and so until
now all occurances of #pragma pack have been ignored!  (You can test
this for yourself by compiling with an older toolchain and with
--Wunknown-pragmas specified).

With the new code in it, defining HANDLE_PRAGMA_PACK_PUSH_POP
automatically enables HANDLE_PRAGMA_SYSV (well actually just the
handling of #pragma pack(<n>), since the Microsoft syntax is an
extension of the basic syntax.
 
: > and	b. If so, is there any documentation on how the pragma is
: > 	supposed to behave.
: 
: I thought it was a pretty typical implementation of pragma pack, but
: I'm surely biased by a decade of SCO experience. :-)

No, you are right.  I think that it is just that until now, the i386
toolchains have been ignoring all occurances of #pragma pack.


So, how to fix the situation ?

Here I am a bit stumped.  Your system header files specify that the
structures are packed, but when gcc starts using the packed structures
things explode.  Hmmm...

You know far about OpenServer than I do.  Does my explanation above
suggest a course of action for you ?

Cheers
	Nick



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]