This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gcc vs. VC++ and UNIONS


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





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]