Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable interface keyword on visual C++ Express 2008?

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.

like image 603
bcsanches Avatar asked Nov 18 '08 17:11

bcsanches


People also ask

What version of c++ is in Visual Studio 2010?

C++0x Core Language Features Visual Studio 2010 gives developers powerful new core language features from the upcoming C++0x standard.

What version of c++ is in Visual Studio 2015?

Basically, Visual Studio 2015 supports compiler Visual C++ 14.0.

What version of c++ does Visual Studio 2012 use?

C++11 features in Visual Studio 2012.

What is Microsoft Visual Studio c++?

MSVC is proprietary software; it was originally a standalone product but later became a part of Visual Studio and made available in both trialware and freeware forms. It features tools for developing and debugging C++ code, especially code written for the Windows API, DirectX and . NET.


3 Answers

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 ..

like image 59
Sebastian Brandt Avatar answered Nov 03 '22 13:11

Sebastian Brandt


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.

like image 28
wimh Avatar answered Nov 03 '22 14:11

wimh


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.

like image 4
Timo Geusch Avatar answered Nov 03 '22 12:11

Timo Geusch