Ticket #16 (closed enhancement: fixed)

Opened 17 months ago

Last modified 7 months ago

PACKED and __attribure__((packed)) aren't defined in SUN CC

Reported by: jerryyu Owned by: zany
Priority: major Milestone:
Component: openobex-lib Version:
Keywords: Cc:

Description

PACKED and attribure((packed)) aren't defined in SUN CC, so they doesn't work in SUN C compiler. For the patch, at first if it's SUN CC will be checked. If it's Sun CC, both PACKED and attribute((packed)) will be defined to null.

Attachments

openobex-01-sun-studio.diff (1.3 KB) - added by jerryyu 17 months ago.
openobex-03-PACKED.diff (0.8 KB) - added by zany 17 months ago.
openobex-pragma-pack.diff (1.9 KB) - added by zany 7 months ago.
Revised pragma pack patch

Change History

Changed 17 months ago by jerryyu

Changed 17 months ago by zany

Changed 17 months ago by zany

  • owner changed from somebody to zany
  • status changed from new to assigned

After each struct we need to end the packing by appending #pragma pack()

This needs to be reviewed on win32

Changed 17 months ago by zany

The symbol _WIN32 flags the platform not the compiler, which would be gcc anyway? If every other compiler recognises #pragma pack, this should be the portable way

#ifdef __GNUC__
#define PACKED __attribute__ ((packed))
#else
#define PACKED
#endif

#pragma pack(1)
struct {...} PACKED ;
#pragma pack()

Changed 17 months ago by hsattler

Yes, using the GNUC will save us a lot. MSVC also only supports pragma. However, why using that at all? According to http://gcc.gnu.org/onlinedocs/gcc/Pragmas.html gcc also supports the pragma statements.

Note that it would be better to use #pragma pack(push,1) and #pragma pack(pop)

Changed 17 months ago by zany

Nice. I can confirm that #pragma pack works on GCC 4.1 as well as GCC 3.4. Using push and pop would be nice and clean, it's a problem with certain gcc targets though. E.g. sparc-sun-solaris2.9/3.4.6 target does not support push and pop.

Changed 7 months ago by zany

Revised pragma pack patch

Changed 7 months ago by zany

  • type changed from defect to enhancement

Revised patch. Needs review.

Changed 7 months ago by zany

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.