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
You can define WIN32_LEAN_AND_MEAN to avoid inclusion of this definition. See MSDN Docs
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.
I faced a similar problem while compiling C++ code which included a dbus header file. since dbus has several functions where it uses "interface" as an I/P parameter name, which happens to be C++ keyword, I got following error: error: expected ',' or '...' before 'struct'
.
When I tried this:
#ifdef interface
#undef interface
#endif
it solved the issue. Not sure if using dbus C++ binding would have been better. Anyways I was not using dbus, just had a remote dependeny on one of dbus headers, this solution just worked fine!!
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.
Problem is that MS #defines interface to struct so that
interface Name {...}
can be used in COM c++ code.
(objbase.h:199: #define interface __STRUCT__
)
Just #undef interface
after including Windows.h ..
"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/