views:

91

answers:

2

Hi, i have some sourcecode that I want to compile with VS2008 but there are many errors i have to fix. Now there are some Enums like:

enum
{
BACKGROUND  = 0x00000001,
WEAPON      = 0x00000002,
TRANSPARENT = 0x00000004
}

The problem is that TRANSPARENT is defined as:

#define TRANSPARENT         1

in WinGDI.h

That will cause a compile error like:

error C2143: syntax error : missing '}' before 'constant'

Is it possible to fix that error without renaming the field in the enum and without removing the WinGDI.h from the includes (I don't know where it's included..)

+2  A: 

If you are not using the value TRANSPARENT from WinGDI.h, you can simply add:

#undef TRANSPARENT

before the enum (this is only a workaround, better rename the TRANSPARENT in the enum).

bill
+2  A: 

You can use

#undef TRANSPARENT

but that may cause errors elsewhere, if the WinGDI TRANSPARENT is used afterwards. A (messy) workaround could be:

#ifdef TRANSPARENT
#define _TRANSPARENT TRANSPARENT
#undef TRANSPARENT
#endif

and after your code:

#ifdef _TRANSPARENT
#define TRANSPARENT _TRANSPARENT
#endif
Nathan Clark