[Scummvm-devel] START_PACK_STRUCTS / #pragma pack (Attn porters)

Max Horn max at quendi.de
Wed Mar 29 04:19:02 CEST 2006


Hi folks,

we define various macros which enable us to specify (in a portable  
fashion)  for structs in our code that they shall be packed. In  
particular, these macros:

START_PACK_STRUCTS
END_PACK_STRUCTS
GCC_PACK

The latter is only used for GCC. The former is either not used, to  
#defined to be a certain macro, typically like this:
	#define START_PACK_STRUCTS pack(push, 1)
	#define END_PACK_STRUCTS   pack(pop)
or alternatively
	#define START_PACK_STRUCTS pack (1)
	#define END_PACK_STRUCTS   pack ()
(The difference between the two is in fact negligible for our  
purposes, as long as they are used properly -- so we could unify the  
two. But I digress.)


Now: This particular PRAGMA (i.e. #pragma pack(...)") is an extension  
that (AFAIK) was originally introduced on Windows. GCC 4.x also  
understands it. But still, it's not something that is available on  
all and every compiler.


My question/request: In scummsys.h, lots of ports use this pragma. It  
would be nice if porters could add a short comment stating which  
specific compiler they are targeting with this. In particular, I am  
seeing some odd constructs like:
	#if !defined(__GNUC__)
	#define START_PACK_STRUCTS pack (1)
	#define END_PACK_STRUCTS   pack ()
	#endif
Which implies that every compiler but GCC supports this macro, which  
is plain nonsense. Better would be something like "#if  
MY_COMPILER_USED ...".
So, if possible, surround those #defines with proper checks for the  
compiler, or, if there really is only one compiler for your target,  
or they all behave identical in this regard, please document it with  
a simple one-line comment in scummsys.h




Cheers,
Max




More information about the Scummvm-devel mailing list