sonjeheon / lz4

Automatically exported from code.google.com/p/lz4
0 stars 0 forks source link

Malformed pragma warning when building with Sun Studio 12 compiler #81

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile lz4.c on Solaris machine using Sun Studio compiler 

What is the expected output? What do you see instead?

Expected: Compilation without warnings

What I see: 
"lz4.c", line 184: warning: ignoring malformed #pragma pack(n)
"lz4.c", line 194: warning: ignoring malformed #pragma pack(n)

<snip>

What version of the product are you using? On what operating system?
lz4 rev101,  Solaris Sparc/x86 with Sun Studio 12.3

Please provide any additional information below.
Documentation of the Sun Studio 12 pack pragma:
http://docs.oracle.com/cd/E19205-01/819-5267/bkbkl/index.html

__SUNPRO_CC would be a suitable Predefined Macro to check

Original issue reported on code.google.com by oliver.s...@gmail.com on 21 Aug 2013 at 12:35

GoogleCodeExporter commented 9 years ago
Correction: __SUNPRO_CC is only predefined when using the Sun Studio C++ 
compiler, __SUNPRO_C is predefined when using the C compiler

Original comment by oliver.s...@gmail.com on 21 Aug 2013 at 1:20

GoogleCodeExporter commented 9 years ago
So, the line :
#  ifdef __IBMC__

would become :
#if defined(__IBMC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)

?

Original comment by yann.col...@gmail.com on 21 Aug 2013 at 2:00

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
yes, and you have to handle the "pop" too. This is how I patched it:

#if defined(__SUNPRO_CC) || defined(__SUNPRO_C)
#   define LZ4_SUNSTUDIO
#endif

#if !defined(LZ4_FORCE_UNALIGNED_ACCESS) && !defined(__GNUC__)
#  if defined(__IBMC__) || defined(LZ4_SUNSTUDIO)
#    pragma pack(1)
#  else
#    pragma pack(push, 1)
#  endif
#endif

typedef struct { U16 v; }  _PACKED U16_S;
typedef struct { U32 v; }  _PACKED U32_S;
typedef struct { U64 v; }  _PACKED U64_S;
typedef struct {size_t v;} _PACKED size_t_S;

#if !defined(LZ4_FORCE_UNALIGNED_ACCESS) && !defined(__GNUC__) 
#  if !defined(LZ4_SUNSTUDIO)
#    pragma pack(pop)
#  else
#    pragma pack()
#  endif
#endif

Original comment by oliver.s...@gmail.com on 21 Aug 2013 at 3:28

GoogleCodeExporter commented 9 years ago
OK

Original comment by yann.col...@gmail.com on 22 Aug 2013 at 9:22

GoogleCodeExporter commented 9 years ago
Fixed into r103.

Original comment by yann.col...@gmail.com on 9 Sep 2013 at 9:10