 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Alex Bakaev [TeamB] Guest
|
Posted: Thu Apr 01, 2004 4:56 pm Post subject: Re: Linking a library with 1-byte data alignment in BCB5 |
|
|
Richard Hufford wrote:
| Quote: | Thank you! Thank you! Thank you! The problem was that my library was
using enums as int, but my project was not. This explains why 4-byte
|
Yes, the size of enums is the ugly cousing of alignment. I should've
thought of mentioning that :)
..a
|
|
| Back to top |
|
 |
Maurice Barnum Guest
|
Posted: Tue Apr 13, 2004 7:57 pm Post subject: Re: Linking a library with 1-byte data alignment in BCB5 |
|
|
| Quote: | I suggest you use the
#pragma alignment
Thank you! Thank you! Thank you! The problem was that my library was
using enums as int, but my project was not. This explains why 4-byte
alignment partially worked. I tried the #pragma alignment directive a week
ago, but I couldn't get the message to appear. (Not only do you have to
enable warnings, but you also have to enable general messages separately in
the project options.) I have a much better idea of what's going on, now.
|
short vs. long enums. type checking versus none..
aaaaahhhhhhhhhhhhhhhh!!!!!!!!!!!!!!!!!!
i have felt your pain.
anyway, i'd suggest that all of your library's headers push and pop
the appropriate ABI compiler options so this won't happen again.
"ABI compiler options" meaning those that change the way objects are
arranged in memory.
doing it explicitly:
#ifndef foo_h_
#define foo_h_
#ifdef __BORLANDC__
#pragma option push -a1 -b- -V-x -V-e // etc.
#endif
// ... blah blah blah ...
#ifdef __BORLANDC__
#pragma option pop
#endif
#endif // !foo_h_
or you can use a separate pre/post headers. if you go that path, you
need to make sure the headers are not guarded and that they disable the
warning you get if push/pop aren't balanced in a header file.
// lib_pre.h: do not header guard this file!
#ifdef __BORLANDC__
#pragma nopushoptwarn
#pragma option push -a1 -b -pc -V-x -V-e
#endif
// lib_post.h: do not header guard this file
#ifdef __BORLANDC__
#pragma nopushoptwarn
#pragma option pop
#endif
you'll see the former technique used in the rtl headers, and the
latter in the visibroker headers. vcl hpp files use a magic variant
built in to the compiler ("#pragma delphiheader begin",
"#pragma delphiheader end").
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|