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

Max Horn max at quendi.de
Wed Mar 29 05:28:05 CEST 2006


Am 29.03.2006 um 14:55 schrieb Marcus Comstedt:

>
> Max Horn <max at quendi.de> writes:
>
>> 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.
>
>
> The DC port uses these pragmas, and I compile with GCC 3.4.2, not GCC
> 4.x.  So it's not 4.x only.  IIRC it used to work in 3.3.x as well.


Yeah, and at least in some versions of GCC 2.95.3, though I am not  
sure if that was standard or just a hack made by certain people. I  
didn't mean to say that only GCC 4.x supports it :-). So my statement  
was misleading, sorry.

Unfortunately the GCC manual is not really forthcoming when it gets  
to trying to find out when a given feature was introduced precisely :-/.
But if we determine that all GCC versions since a certain point  
support that pragma (and support it correctly), we could even get rid  
of GCC_PACK. Still, I'd prefer if we explicitly checked for the  
compiler before using that pragma, instead of blindly assuming it  
works (this would also help people who make new ports, I think).

I.e. something like

#if GCC > 3.3 or VISUAL C or Metrowerk > X.Y or ...
  #define START_PACK_STRUCTS ...
#else another compiler
  #define START_PACK_STRUCTS ...
#endif

#ifndef START_PACK_STRUCTS
  #error Unknown compiler and START_PACK_STRUCTS is not defined!
#endif



Cheers,
Max




More information about the Scummvm-devel mailing list