Re: ODBC Fails on Server -- Memory Alignment issue?
What is the byte alignment of the Microsoft DLL's ? Lets assume it's 8. What if you define ODBC structures (handles, etc) as packed 1? Would it create a possible misalignment between the structure in the BSFN vs the one the ODBC Dll's really read? If so, you have to instruct the compiler that the ODBC dll structures should be aligned to 8 bytes.
I've had a similar problem in the past. I had to call up JDE Business functions from a foreign process running as a windows service. I was using Client Access data queue API's on one side (8 bit alignment) calling up JD system functions (JDB_OpenTable, Etc) on the other side (1 bit). I had to compile the service packed in 8 bits (standard alignment) with the "#pragma pack" instruction on targeted parts of the code.
This is done by issuing the following statement prior to each structure declaration:
/* Begin : Push current packing and force 8 bits
#pragma push
#pragma pack 8
/* ------ Define ODBC Structures here -----
ODBC_CALL_DATA_STRUCT_TYPE dsODBC_CallStructure={0};
ODBC_CALL_DATA_STRUCT_TYPE dsODBC_OtherCallStructure={0};
/* End : Restore alignment
#pragma pop
/* Begin : Push current packing and force 8 bits
#pragma push
#pragma pack 8
/* ------ Include ODBC header files here --
#include <ODBCHeaders.h>
/* End : Restore alignment
#pragma pop
After I completed the code modification, I installed the service and it runs perfectly since then (3 years ago, windows NT 4.0).
For more information on the pack compiler directive:
http://tinyurl.com/2b9yo
Salutations sinceres!
Sebastien Leclerc