1

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

einpoklum
  • 118,144
  • 57
  • 340
  • 684
PatrykB
  • 1,579
  • 1
  • 15
  • 24
  • 3
    cub uses cuda, cuda is incompatible with intellisense, and a single cub header file is going to include a lot of code, since it is a template library. There are all sorts of questions here on the SO `cuda` tag discussing intellisense errors and what may be done about them. Alternatively, you can have VS2015 not report those types of errors. – Robert Crovella Jul 08 '17 at 08:16
  • Yes, you edited that into your question after I read your initial draft and responded. I've removed that statement from my first comment. – Robert Crovella Jul 08 '17 at 08:17
  • @RobertCrovella How can I force VS2015 to not report these errors? Do you think about switching off IntelliSense? – PatrykB Jul 08 '17 at 08:19
  • In the window where intellisense reports the errors, there is a selection box at the top of the window that currently says "Build + Intellisense" in your picture. If you change that to "Build" then the intellisense errors won't show up in that window. I believe they would still show up as an underline or similar in any code editing window you opened. – Robert Crovella Jul 08 '17 at 08:22
  • Have you looked at any of the questions that ask about intellisense and CUDA compatibility? There are a number of suggestions to try. Whether or not any of them will completely eliminate the report by themselves, I don't know. – Robert Crovella Jul 08 '17 at 08:23
  • I will do that now. Thank you. – PatrykB Jul 08 '17 at 08:26
  • 1
    something like what is suggested in the question [here](https://stackoverflow.com/questions/28322961/determining-if-a-file-is-parsed-by-qt-creator-cuda-syntax-highlighting), included before you include your cub header. – Robert Crovella Jul 08 '17 at 08:27
  • @RobertCrovella I believe I found an acceptable solution, check my answer. – PatrykB Jul 08 '17 at 22:44

1 Answers1

1

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...).
PatrykB
  • 1,579
  • 1
  • 15
  • 24