Hi Vincent, I didn't see any responses to your questions, so ...
Vincent Torri wrote: > Hey, > > i am porting a linux library which uses __attribute__((__packed__)) > (compiled with gcc). > > I think that suncc allows, like vc++, the use of #pragma pack(1) to do > the equivalent thing. > > I also read that __attribute__((__packed__)) is also supported on > recent opensolaris versions. So: The "packed" attribute is available in Sun Studio 12 update 1, which is the latest release. > > 1) Is it really the case, and from which version > __attribute__((__packed__)) is available (which version of _SUNPRO_C > should I check) ? Check for __SUNPRO_C == 0x510 > 2) is it better to use #pragma pack(1) instead of > __attribute__((__packed__)) if the latter is available ? Personal preference, I suppose. #pragma pack(1) applies to all subsequent struct/union definitions whereas the packed attribute must be applied to each struct/union declaration. The packed attribute, though, can be used in typedefs and then used to declare other variables needed by a program, which is nice. In general, I'd say use the packed attribute ... it's a cleaner approach, in my opinion. --Dave