Pelles C forum

Pelles C => Bug reports => Topic started by: Mikehg on October 13, 2004, 12:04:12 AM

Title: pragma pack behavior
Post by: Mikehg on October 13, 2004, 12:04:12 AM
Hi Pelle,

If I use the include files this works fine, but if I use the Pragma directly I get a whole mess of errors? Are the include files the only way to use these directives?

Thanks,
Mike H.

#pragma pack(push,1)


typedef struct _BMP_HEADER
{
   char fIdentity[2];
  long  fFileSize;
  long  fReserved;
  long  fOffset;
  long  fHeaderSize;
  long  fWidth;
  long  fHeight;
  WORD  fPlanes;
  WORD  fBPP;
  long  fCompression;
  long  fDataSize;
  long  fHResolution;
  long  fVResolution;
  long  fColors;
  long  fImpColors;
}BMP_HEADER, *LPBMP_HEADER;

#pragma pack(pop)
Title: pragma pack behavior
Post by: Pelle on October 13, 2004, 01:11:05 AM
Hello Mike,

No, the include files are just for Microsoft compatibility ("convenience").

If I change WORD to (unsigned) short in your example, I have no problems compiling the code. No errors. No problems. (With POCC 2.90 - but I don't think anything have changed in this part recently).

Pelle
Title: pragma pack behavior
Post by: Mikehg on October 15, 2004, 03:11:48 PM
Hi Pelle,

It still seems a little strange that it works if you use the #include instead of the pragma directly? Do you agree?

Thanks again,
Mike H.
Title: pragma pack behavior
Post by: Pelle on October 15, 2004, 03:39:56 PM
Hello Mike,

I agree, but since your example works here, I'm not sure what to do. The #pragma directive is handled by the compiler, after the preprocessor have merged the source file and include files into one big 'file', so it shouldn't matter *where* the #pragma appears. It will only be handled in one place in the compiler...

Pelle
Title: pragma pack behavior
Post by: Mikehg on October 15, 2004, 10:22:07 PM
Hi Pelle, I found the problem and A weird one at that :)

It seems to be a bug that was output by BCX.

At the end of the line containing the pragma, it was adding 2 carriage returns and 1 line feed. PellesC didn't like that all :)

Thanks for your time and of course the terrific work you've done!

Mike H.
Title: pragma pack behavior
Post by: Pelle on October 15, 2004, 11:11:39 PM
Quote from: "Mikehg"
Hi Pelle, I found the problem and A weird one at that :)

It seems to be a bug that was output by BCX.

At the end of the line containing the pragma, it was adding 2 carriage returns and 1 line feed. PellesC didn't like that all :)

Thanks for your time and of course the terrific work you've done!

Mike H.


Thanks. Good that you found it. I will see if it's possible to do something about extra carriage returns in the compiler (just in case...).

Pelle