PDFNet for C++: How to avoid errors due to incompatible struct alignment?

Q:

How to avoid runtime errors due to incompatible struct alignment?

I am getting a runtime stack corruption reported by dev studio near a
ColorPt variable when leaving it's scope. It says: "Run-Time Check
Failure #2 - Stack around the variable 'pdfColor' was corrupted."

I have reduced the function to the following:

static void DoSomething()
{
  ColorPt pdfColor;
}
----
A:

PDFNet is compiled with 8 byte alignment (which is the default VC
setting). The headers are included in the client's project which may
not be set to 8 byte alignment. Use of these classes with different
alignment can result in access violations and/or bad values when data
is assigned to or retrieved from the member variables.

To avoid the problem in our project use the 'pack pragma' to surround
all PDFNet includes. For example:

#pragma pack(push, 8)

#include <PDF/PDFNet.h>
#include <PDF/ElementReader.h>
...

#pragma pack(pop)