Clang-IntelliSense bug on "static const initialization"?

Sysprogs forums Forums VisualGDB Clang-IntelliSense bug on "static const initialization"?

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #13414
    kurt
    Participant

    In the attached const_static.png:

    1. Line-4 is a constant.  Why is it being flagged as an error?
    2. Line-5:  What does the white bracket mean?  When I click on the bulb to fix it, the suggestion doesn’t make sense (see huh.png)
    Attachments:
    You must be logged in to view attached files.
    #13418
    support
    Keymaster

    Hi,

    This is strange. We have just tried reproducing this on a clean project, but could not get the errors you are experiencing. Most likely your project picked up a wrong C++ language standard setting.

    We could help you pinpoint this if you could let us know the project type (Make, MSBuild, CMake, Advanced CMake) and whether you can reproduce the same behavior on a clean “Hello, World” project.

    #13446
    kurt
    Participant

    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:

    #ifdef unix
    #define const
    #endif

    I then added this to test:

    const int i = 0;
    printf("%d\n", ++i);

    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.

     

     

    #13468
    support
    Keymaster

    Hi,

    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:

    #ifdef SYSPROGS_CODESENSE
    #undef unix
    #endif
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.