3

TL;DR:

How can I persuade Nsight that I'm using C++11? In other words, where do I set the relevant discovery options? Building with -std=c++11 is working, even from within Eclipse. I'm talking about the Indexer having troubles with defines.

Longer version:

C++11 functions are marked as unresolved in the Nsight editor, because the __cplusplus define is 199711L, instead of something >= 201103L.

When I made the project, in Project Properties > Build > Discovery Options the Automate discovery of Path and Symbols option was checked for every language and every Build Configuration. There was a note on the bottom of the Properties windows that said that the discovery method is deprecated, so I unchecked it for every language and for every Build Configuration.

Now, under Project Properties > General > Preprocessor Include Paths, Macros etc. there are system provided paths and defines (more precisely, provided by the Providers). In the list I can see the problematic __cplusplus. I can redefine it under the CDT User Setting Entries and indeed it will be the new value after rebuilding the Index, but then whenever I click something in the editor I get an error:

An internal error occurred during: "Notifying selection listeners".
org.eclipse.cdt.internal.core.index.composite.CompositingNotImplementedError

That route is a dead end obviously. Another option is to define the new __cplusplus in Project Properties > General > Paths and Symbols under the Symbols tab. I can see the "wrong" __cplusplus there as well. Redefining it there gives me the same error as above, after rebuilding the Index, when clicking in the editor.

Also, what the hell is the CDT Managed Build Setting Entries Provider? I don't see any options for it. Where is it configured?

When I try to use the CDT GCC Built-in Compiler Settings Provider I see a field where I can input command line arguments, but putting -std=c++11 there has no effect, as that entry doesn't produce a __cplusplus define.

Offtopic:

In other news, C++11 support is great with the CUDA Toolkit 7.0, on the command line and in the makefiles. It saddens me greatly that nVidia settled on Eclipse. Whatever I did with it, I've only encountered trouble with Eclipse. Takes me a week just to set up the IDE for a project. I hate it so much.

Alfis
  • 73
  • 6
  • 1
    If you do not like Eclipse, why don't you use another IDE? You are free to use any IDE you want. Aside from that, did you try what is suggested [here](http://stackoverflow.com/questions/9131763/eclipse-cdt-c11-c0x-support) and [here](http://stackoverflow.com/questions/17131744/eclipse-cdt-indexer-does-not-know-c11-containers)? – m.s. Apr 19 '15 at 05:43
  • 1
    I do hate Eclipse, but I don't use another IDE because Eclipse (Nsight) is part of the CUDA Toolkit. I don't think any other IDE would recognize CUDA kernels and highlight the syntax accordingly. Let alone support debugging with cuda-gdb the way Nsight does. Aside from that, I did try those suggestions. Most of them refer to older version, and some of them even suggest the same things I described above. And when I do them, I get the error I wrote above. – Alfis Apr 19 '15 at 12:01
  • 1
    I have the same problem. Did you solve it? – Flamefire Jun 05 '15 at 14:30
  • Not really. It's funny that when using GCC alone it works as expected, with `-std=c++11`, but not with NVCC. For example, C++ project is all cool with C++11 features, but a CUDA project is not. I stopped caring for it and endure a few red lines. I compile it with a custom makefile. Through the IDE only `make all` is called. – Alfis Jun 06 '15 at 18:33

1 Answers1

2

I experienced a similar problem with the indexer when using the native compiler; however, the cross compiler worked correctly. When using the native compiler, __cplusplus was defined as 199711L even though the C++ dialect had been set to C++11 and the index rebuilt.

The indexer can pick up the C++11 settings by going to

Project Settings->C/C++ General->Preprocessor Include Paths, Macros etc.->Providers->CDT GCC Built-in Compiler Settings

and doing:

  1. Uncheck Use global provider shared between projects.
  2. Add -std=c++11 to Command to get compiler specs like so:

    ${COMMAND} -std=c++11 ${FLAGS} ...

__cplusplus should now be correctly set.

wandns
  • 21
  • 2
  • Which one do you mean with native compiler? GCC? – Alfis Nov 20 '15 at 08:38
  • I mean the version of GCC that generates binaries for the system running the compiler. In my case, the native compiler is GCC running on a x86_64 laptop; not the cross compiler, which in my case, builds ARM binaries.. – wandns Nov 22 '15 at 00:10
  • I can't try it out as I no longer have Eclipse installed. I hope that this is a correct solutions, and not something Nsight specific. – Alfis Nov 27 '15 at 01:37