I am using a CMake project, with CXXFLAGS = -std=c++11
In one of my header files, there was a legacy code the removed const:
I then added this to test:
The compilation on the VM flagged the error, so clearly unix is not defined. I wondering who defined unix for me. After some searching, it actually came from the gcc_Debug.h file. This file says it is generated “based on my GCC”.
Question 1: If it compilation didn’t use the flag, why did the IntelliSense file added that flag?
If I removed the -std=c++11, the compilation did not flag the error (interesting…). So maybe my GCC configuration did have unix, but the c++11 flag removed it, but the visualgdb IntelliSense file didn’t capture this? (I’m new to Linux).
Question 2: If it’s my configuration problem, anything I can do to remedy this? It seems like I am not supposed to edit the IntelliSense file.
VisualGDB generates the gcc_Debug.h file during toolchain testing (it runs gcc with the arguments specified in your project properties and in a special mode where it dumps all implicit preprocessor macros). Most likely your project somehow explicitly overrides the ‘unix’ macro and VisualGDB doesn’t catch it.
You can resolve this by either editing the gcc_Debug.h file (it won’t be regenerated unless you edit some toolchain-related settings in VisualGDB GUI) or adding something like this to one of your commonly used header files: