Hi All,
I found Windows AMD64 compiler behaving differently When used on
Windows XP SP2 and Windows 2K professional. (both using Windows 2003
SP1 SDK - April edition)
I've a .tlb which is imported in my .cpp file. This typelibrary has a
structure defined inside and I'm using it in my code.
XXX.cpp:
#import COMLib.tlb
using namespace COMLib;
....
main()
{
COMLib::STRUCTDAT structData;
}
....
//
When the project is compiled on XP SP2 with VS2003 IDE, the tlh code
generated looks like follows:
// Created by Microsoft (R) C/C++ Compiler Version 14.00.40310.41
(cda64a29).
//...
#pragma once
#pragma pack(push, 8)
namespace COMLib {
....
....
#pragma pack(push, 4) //////Here is the difference, on WIN2k, this
value is 8.
struct STRUCTDAT
{
unsigned long ValidationDataLength;
unsigned char * ValidationData;
};
#pragma pack(pop)
....
....
}
#pragma pack(pop)
While on Win2k the same project under same environment the tlh
generated looks like
// Created by Microsoft (R) C/C++ Compiler Version 14.00.40310.41
(b739b039).
//...
#pragma once
#pragma pack(push, 8)
namespace COMLib {
....
....
#pragma pack(push, 8) //////Here is the difference, on WINXP, this
value is 4.
struct STRUCTDAT
{
unsigned long ValidationDataLength;
unsigned char * ValidationData;
};
#pragma pack(pop)
....
....
}
#pragma pack(pop)
Because of the wrong alignment on XP, sample built here fails while
built on Win2K succeeds. Does anyone know why compiler is behaving
this way? How to make it build correctly on WinXP?