CUDA 8, C++ 11, and VS 2015

Looked forward to CUDA 8 so that I’d get full C11 support. Now that it’s here, I get stuff to compile, and apparently work, but I’m getting all kinds of funky errors/warnings. I guess I’m not sure what flags are supposed to go where?

First and foremost, I get a “nvcc warning : The -std=c++11 flag is not supported with the configured host compiler. Flag will be ignored.” error from nvcc, but if I don’t have the flag, stuff doesn’t compile.

Then I get all kinds of warnings about “constexpr” is ignored here in Microsoft mode. But that’s a C++11 feature, why is that a problem? These errors are coming from a .hpp file that compiles just fine when included with other source files in the same solution.

What’s up, is C++11 really supported with NVCC on VS2015?

On windows, there is no need to specify the -std=c++11 flag. nvcc includes c++11 support automatically on windows platforms.

Regarding the other issues, you would have to provide an actual example to look at.

Thank you. That got rid of those warnings. But I still get a slew of others in NVCC on code that compiles fine in VS2015. Some are:

1>  C:\Users\clwill\Documents\Visual Studio 2015\Projects\michronos\michronos>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\nvcc.exe" -gencode=arch=compute_50,code=\"sm_50,compute_50\" --use-local-env --cl-version 2015 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64"  -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include"  -G   --keep-dir x64\Debug -maxrregcount=0  --machine 64 --compile -cudart static --std=c++11 -g   -DWIN32 -DWIN64 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /FS /Zi /RTC1 /MDd " -o x64\Debug\imageAnalyzer.cu.obj "C:\Users\clwill\Documents\Visual Studio 2015\Projects\michronos\michronos\imageAnalyzer.cu"
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(1335): warning : template parameter "T" is not used in declaring the parameter types of function template "nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::basic_json<T,<unnamed>>(NumberIntegerType)"
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(1430): warning : template parameter "T" is not used in declaring the parameter types of function template "nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::basic_json<T,<unnamed>>(NumberUnsignedType)"
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2222): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2252): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2279): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2301): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2323): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2353): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2382): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2410): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2438): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2460): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2482): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2504): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2531): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2554): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2717): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2731): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2743): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2755): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2767): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2779): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2791): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2803): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(6525): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(6531): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(6543): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(6697): warning : invalid friend declaration
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(9444): warning : invalid friend declaration
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(6009): warning : reference to local variable of enclosing function is not allowed
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(1335): warning : template parameter "T" is not used in declaring the parameter types of function template "nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::basic_json<T,<unnamed>>(NumberIntegerType)"
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(1430): warning : template parameter "T" is not used in declaring the parameter types of function template "nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::basic_json<T,<unnamed>>(NumberUnsignedType)"
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2222): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2252): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2279): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2301): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2323): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2353): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2382): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2410): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2438): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2460): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2482): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2504): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2531): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2554): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2717): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2731): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2743): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2755): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2767): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2779): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2791): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(2803): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(6525): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(6531): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(6543): warning : "constexpr" is ignored here in Microsoft mode
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(6697): warning : invalid friend declaration
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(9444): warning : invalid friend declaration
1>c:\users\clwill\documents\visual studio 2015\projects\michronos\michronos\json.hpp(6009): warning : reference to local variable of enclosing function is not allowed

If you want I can show you the file json.hpp, but as I noted, it compiles just fine in other modules.

Thanks again.

Further, I notice I don’t get the “nvcc warning” above in the first iteration through the nvcc, but I do get this:

1>CUDACOMPILE : nvcc warning : The -std=c++11 flag is not supported with the configured host compiler. Flag will be ignored.
1> imageAnalyzer.cu

Later on down, apparently as nvcc is handing it off into the VS compiler. I can’t find anywhere where I’m setting --std=c++11, but as you see in the command line I posted above, it says it’s there. Where that’s coming from, I have no idea…

Thx again.

I wouldn’t be able to explain warnings associated with a file that I haven’t seen. I’m not saying I’ll do much with it anyway, even if you post it.

You can file a bug if you wish.

As a workaround, you can also partition your code/project so that the offending header file only gets included in .cpp files, not .cu files. That should eliminate the issue. If need be, you can stitch the files together with wrapper functions to call between .cpp and .cu modules.

Regarding the additional warning about -std=c++11, that doesn’t happen unless you specify it in your project somewhere.

If you doubt that, start over with a empty CUDA C++ project, or load one of the CUDA sample projects. THey should not give such a warning.