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.
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:
- Uncheck Use global provider shared between projects.
Add
-std=c++11
to Command to get compiler specs like so:${COMMAND} -std=c++11 ${FLAGS} ...
__cplusplus
should now be correctly set.
来源:https://stackoverflow.com/questions/29724501/eclipse-nsight-7-0-and-c11-support