value of __cpluspluc macro in intellisense

Sysprogs forums Forums VisualGDB value of __cpluspluc macro in intellisense

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #35868
    Timo
    Participant

    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?

    #35869
    support
    Keymaster

    Hi,

    The easiest way would be to manually patch the .vcxproj file, conditionally adding/Zc:__cplusplus when the DesignTimeBuild 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.

    #35872
    Timo
    Participant

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

    #35931
    buga
    Participant

    I 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 the LanguageStandard based on CPPLanguageStandard, 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>

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.