visual-studio-2015cudaintellisensecub

Including the CUB header triggers many Visual Studio Intellisense errors


Whenever i include <cub/cub.cuh> header file, visual studio's IntelliSense reports thousands of errors.

As you can see in the attached screenshot, application consists of empty main() function and a include line.

I have defined additional include directories and additional library directories in project properties. I have not made any other changes.

My setup consist of visual studio community 2015, cuda 8.0.61 and cub 1.7.0 library.

Is there anything I can do to fix this error?

IntelliSense behavior


Solution

  • I would like to thank Robert Crovella for pointing me in the right direction.

    Permanent solution:

    #ifndef __INTELLISENSE__
    
    #include <cub/cub.cuh>
    
    // And other troublesome libraries or code-blocks....
    
    #endif
    

    The Visual Studio's __INTELLISENSE__ macro is only defined when Visual Studio itself parses the file, not during compilation. Therefore anything inside a code block above will not be checked by IntelliSense algorithms.


    Workaround: (my 1st attempt to fix this problem, can be ignored).

    Step #1:
    In the Visual Studio's Error List window change option Build + IntelliSense to Build Only

    Step #2
    In visual Studio go to: Tools > Options > Text Editor > C/C++ > Advanced and change Disable Error Reporting from False to True

    Explanation:
    This will turn off IntelliSense error check functionality, and by extension will solve my problem. This partial solution will force me to rely only on compiler (build) output, but that is not an issue.

    Like I said, this solution is more like a workaround around without any serious or critical penalty in IntelliSense functionality, NOT a permanent fix. But it works fine.

    Disadvantages:

    1. in my current project, there are functions that are cub wrappers, those functions sometimes are not detected by an autocomplete.
    2. Also if the total error count reaches IntelliSense limit, IntelliSense will stop working. (edit: "without any serious or critical penalty" went straight out of the window...).