www.digitalmars.com         C & C++   DMDScript  

c++ - pragma problem

reply mikaelh delphi.se writes:
Hi,
When i try to compile "Developer's Image Library" (http://www.imagelib.org)
i get stuck on this define statements (and similar ones).

Error message is "alignment must be a power of 2" and a 
warning "unrecognized pragma"

#ifdef _WIN32
#pragma pack(push, bmp_struct, 1)
#endif
typedef struct BMPHEAD
{
ILushort	bfType;
ILint		bfSize;
ILuint		bfReserved;
ILint		bfDataOff;
ILint		biSize;
ILint		biWidth;
ILint		biHeight;
ILshort		biPlanes;
ILshort		biBitCount;
ILint		biCompression;
ILint		biSizeImage;
ILint		biXPelsPerMeter;
ILint		biYPelsPerMeter;
ILint		biClrUsed;
ILint		biClrImportant;
} IL_PACKSTRUCT BMPHEAD;

typedef struct OS2_HEAD
{
// Bitmap file header.
ILushort	bfType;
ILuint		biSize;
ILshort		xHotspot;
ILshort		yHotspot;
ILuint		DataOff;

// Bitmap info header.
ILuint		cbFix;
ILuint		cx;
ILuint		cy;
ILushort	cPlanes;
ILushort	cBitCount;
/*ILuint		ulCompression;
ILuint		cbImage;
ILuint		cxResolution;
ILuint		cyResolution;
ILuint		cclrUsed;
ILuint		cclrImportant;
ILushort	usUnits;
ILushort	usReserved;
ILushort	usRecording;
ILushort	usRendering;
ILuint		cSize1;
ILuint		cSize2;
ILuint		ulColorEncoding;
ILuint		ulIdentifier;*/
} IL_PACKSTRUCT OS2_HEAD;
#ifdef _WIN32
#pragma pack(pop, bmp_struct)
#endif

/Mikael
Jul 15 2002
parent reply "Walter" <walter digitalmars.com> writes:
<mikaelh delphi.se> wrote in message news:aguh0h$1n74$1 digitaldaemon.com...
 Hi,
 When i try to compile "Developer's Image Library"
(http://www.imagelib.org)
 i get stuck on this define statements (and similar ones).

 Error message is "alignment must be a power of 2" and a
 warning "unrecognized pragma"

 #ifdef _WIN32
 #pragma pack(push, bmp_struct, 1)
 #endif
What alignment are you setting it to?
Jul 15 2002
parent reply mikaelh delphi.se writes:
What alignment are you setting it to?
Sorry, I'm all lost now. I have never using these options before. But I found something under Settings/Build/Struct Alignment which are set to quad word, and tested all other options but it gave not better results.
Jul 15 2002
parent reply "Walter" <walter digitalmars.com> writes:
<mikaelh delphi.se> wrote in message news:agutk0$25at$1 digitaldaemon.com...
What alignment are you setting it to?
Sorry, I'm all lost now. I have never using these options before. But I found something under Settings/Build/Struct Alignment which are set to quad word, and tested all other options but it gave not better results.
The #pragma pack is used to set the alignment within the source code. Your code passes it a macro or something, what value does that expand to? (The value needs to be a power of 2.)
Jul 15 2002
next sibling parent mikaelh delphi.se writes:
The #pragma pack is used to set the alignment within the source code. Your
code passes it a macro or something, what value does that expand to? (The
value needs to be a power of 2.)
If i undestand the help file right it must be 1 in this line below? #pragma pack(push, bmp_struct, 1) I tried them all (2,4,8,16)
Jul 15 2002
prev sibling parent reply Christof Meerwald <cmeerw web.de> writes:
On Mon, 15 Jul 2002 10:46:25 -0700, Walter wrote:
[ #pragma pack(push, bmp_struct, 1) ]
 The #pragma pack is used to set the alignment within the source code. Your
 code passes it a macro or something, what value does that expand to? (The
 value needs to be a power of 2.)
I guess DM doesn't correctly understand the "Visual C++" extensions of the pack pragma. "bmp_struct" is an identifier for the "pragma pack" stack and the alignment is 1. (see http://msdn.microsoft.com/library/en-us/vclang/html/_PREDIR_pack.asp) bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net?
Jul 15 2002
parent "Walter" <walter digitalmars.com> writes:
"Christof Meerwald" <cmeerw web.de> wrote in message
news:agv657$2drp$1 digitaldaemon.com...
 On Mon, 15 Jul 2002 10:46:25 -0700, Walter wrote:
 [ #pragma pack(push, bmp_struct, 1) ]
 The #pragma pack is used to set the alignment within the source code.
Your
 code passes it a macro or something, what value does that expand to?
(The
 value needs to be a power of 2.)
I guess DM doesn't correctly understand the "Visual C++" extensions of the pack pragma. "bmp_struct" is an identifier for the "pragma pack" stack and the alignment is 1. (see http://msdn.microsoft.com/library/en-us/vclang/html/_PREDIR_pack.asp)
Thanks for the reference. More accurately, MS changed it from what it was before. In any case, replacing it with: #pragma pack(push, 1) should work.
Jul 15 2002