Sysprogs forums › Forums › VisualGDB › value of __cpluspluc macro in intellisense
- This topic has 3 replies, 3 voices, and was last updated 3 months ago by buga.
-
AuthorPosts
-
August 15, 2024 at 06:51 #35868TimoParticipant
Im using the “Regular VC++ IntelliSense” option in the VisualGDB Project Propertires.
I’ve added a library that uses the __cplusplus macro to determine the supported languages. The compiler sets this value correctly, but microsoft does not set this value correctly unless a certain command line parameter is passed.
Intellisense looks for this switch in the command line, and also corrects its syntax highlighting accordingly.
Of course, since the actual compiler is gcc, i can’t just add the option into the Additional Options field, since gcc uses a very different command line. If i do it, the program simply wont compile anymore (though syntax highlighting will work if i do that).
Unfortunately, there is also no dedicated GUI button in visual studio for this, and VisualGDB seems to reuse the same AdditionalOptions xml entry, so i can’t pull of a trick like last time.
Manually #defining a macro of the same name also doesn’t seem to trick Intellisense, it will keep using its predefined value.
Is there any way i can pass the /Zc:__cplusplus command to IntelliSense while still being able to compile with gcc?
August 15, 2024 at 09:30 #35869supportKeymasterHi,
The easiest way would be to manually patch the .vcxproj file, conditionally adding
/Zc:__cplusplus
when theDesignTimeBuild
variable is set. This should affect IntelliSense, but not the actual build.Another option would be to checking the _MSC_VER macro in some common header file, and redefining __cplusplus if it is set.
August 16, 2024 at 04:43 #35872TimoParticipantI went the .vcxproj file route. Worked like a charm!
For Posterity:
I added a conditional property group
<PropertyGroup Condition=”‘$(DesignTimeBuild)’!=””>
<IntelliSenseCommandline>/Zc:__cplusplus</IntelliSenseCommandline>
</PropertyGroup>
Then i added the value of the property to the AdditionalOptions line
<AdditionalOptions>-x c++ -fconcepts $(IntelliSenseCommandline) %(AdditionalOptions)</AdditionalOptions>
Now it compiles and highlights correctly!
Thank you for the quick support.
August 23, 2024 at 00:09 #35931bugaParticipantI would recommend adding an additional property, the
LanguageStandard
. It doesn’t mean anything to vgdb, but vs will treat all source files as C++23 instead of C++14. It might be useful.
I’ve tried using defines* in the source or conditions in the *.vcproj file to automatically set theLanguageStandard
based onCPPLanguageStandard
, but neither of them was successful.
(*I modified intellisense.props and introduced __cplusplus_vgdb instead of __cplusplus, then later redefined __cplusplus using __cplusplus_vgdb.)
<div>
<div> <ClCompile></div>
<div> <LanguageStandard>stdcpplatest</LanguageStandard></div>
<div> <AdditionalOptions>$(IntelliSenseCommandline) %(AdditionalOptions)</AdditionalOptions></div>
<div> </ClCompile></div>
</div> -
AuthorPosts
- You must be logged in to reply to this topic.