gcc vs. VC++ and UNIONS

Alt.net tom@alteredworlds.com
Thu Oct 21 12:00:00 GMT 1999


Hi there,

I'm trying to port some Windows C++ code to Linux, and have run into a
non-standard feature of VC++, it seems. Could anyone confirm this - perhaps
I'm missing something here?

MS defines the following:

typedef union _LARGE_INTEGER {
    struct {
        DWORD LowPart;
        LONG HighPart;
    };
    LONGLONG QuadPart;
} LARGE_INTEGER;

Now quite apart from the issues of what I should typedef DWORD, LONG and
LONGLONG to [for x86 Linux], this doesn't seem to be valid C/C++ according
to g++.

G++ seems to want me to supply a name for the struct inside the union, and
so will NOT allow me to access as follows:
LARGE_INTEGER a;
a.LowPart = whatever;
a.HighPart = whatever2;

and then look at a.QuadPart


Any comments? If anyone has the time to spare, do you agree with the
following type mappings?

VC++                g++ [i86 machines only, for now]/Linux        VC++ Help
Description
DWORD            unsigned int
32-bit unsigned integer
LONG                int
32-bit signed integer
LONGLONG     long int
64-bit signed integer

thanks very much,

Tom Gilbert
http://www.AlteredWorlds.com






More information about the Gcc-help mailing list