Re: struct versioning
- From: Ernie Wright <erniew@xxxxxxxxxxx>
- Date: Tue, 29 Apr 2008 17:02:19 -0400
Pres wrote:
Noticed that several windows API's take a size parameter.
i.e. one of the members of the struct is dwSize which is supposed
to be initialized by client code, by taking the sizeof of the struct.
I assume this is to enable versioning of structures
Yes.
To see a specific example, look up Microsoft's definition of the
BITMAPINFOHEADER, BITMAPV4HEADER, and BITMAPV5HEADER structures.
Is this fully standard compliant or are they taking liberties with their
close knowledge of the internals of the compiler.
Assume lib_v1 is compiled with compiler cl_v1 & lib_v2 is compiled
with compiler cl_v2, then it is safe to assume that sizeof(A_v1) would
be the same when compiled with different versions of the same compiler?
You have this part backwards. Compilers that claim to produce output
that works with Windows must be binary-compatible with Windows, not the
other way around.
Windows specifies the structure packing, the endianness, the sizes of
its primitive types (e.g. DWORD), and the calling conventions for any
code that calls or is called by any part of the Windows API.
- Ernie http://home.comcast.net/~erniew
.
- References:
- struct versioning
- From: Pres
- struct versioning
- Prev by Date: Re: 128 bit integer code needed
- Next by Date: Re: Integer to string conversion
- Previous by thread: Re: struct versioning
- Next by thread: Re: struct versioning
- Index(es):
Relevant Pages
|