[Gdal-dev] Structure member alignment suggestion
Ray Gardener
rayg at daylongraphics.com
Fri Jan 27 19:51:18 EST 2006
FWIW, I came across a runtime problem when a project uses a different
structure member alignment (e.g., 4 bytes) than whatever was used to
build GDAL with (normally 8 bytes in MSVC/Pentium). For example, the
OGRSpatialReference class will become misinterpreted. Below are the
current and suggested member layouts:
class CPL_DLL OGRSpatialReference
{
int nRefCount;
OGR_SRSNode *poRoot;
int bNormInfoSet;
double dfFromGreenwich;
double dfToMeter;
double dfToDegrees;
...
};
Suggested:
double dfFromGreenwich;
double dfToMeter;
double dfToDegrees;
OGR_SRSNode *poRoot;
int nRefCount;
int bNormInfoSet;
Another possibility is to enclose structures in
#ifdef MSVC
#pragma(pack, push, 8)
#endif
...
#ifdef MSVC
#pragma(pack, pop)
#endif
Ray
More information about the Gdal-dev
mailing list