views:

1167

answers:

3

I am compiling a legacy C code here and there is a lot of variables and struct members named "interface", but VC2008 express is complaining about these, do you know how to disable this?

I already changed settings to compile the code only as a C code, but no effect on this.

+4  A: 

Do a

#define interface QQInterface

before your code (eg. in the header file), this way everywhere where the keyword interface is used, the compilers sees "QQInterface", which is not a keyword. If all code includes this define, you will not get compiler or linker errors.

Wimmel
It's better instead to add the #define to the project settings instead of a header file.
Adam Rosenfield
I just created another header and forced it to include on the project. But, I discovered that ms already did this (#define interface struct). So I changed to:#ifdef interface#undef interface#endifThis solved the issue.
bcsanches
+1  A: 

"interface" a should not be a keyword in C nor ISO C++. It is a keyword in the Managed Extensions for C++, so, I guess, somewhere in your configuration you are still telling it to create code for .NET. Make sure everywhere is set to "Native Code"

However, it's quite possible that you CANNOT set it to Native Code in the Express edition --- That's just a guess, but it reasonable considering MS positioning of the Express/Standard/Pro editions.

UPDATE: Disregard that last paragraph. MSFT insists that you can create native Win32 apps with VisualC++ Express: http://www.microsoft.com/express/vc/

James Curran
+2  A: 

If you are trying to compile reasonably portable C code, it might be worth disabling the Microsoft language extensions (/Za on the command line, Configuration Properties > C/C++ > Language in VS) and see if the code compiles then.

Timo Geusch