1 // Direct NVCC command line example: 2 // 3 // nvcc ./cuda-cpp14.cu -x cu -I"../include" -l"fmtd" -L"../build/Debug" \ 4 // -std=c++14 -Xcompiler /std:c++14 -Xcompiler /Zc:__cplusplus 5 6 // Ensure that we are using the latest C++ standard for NVCC 7 // The version is C++14 8 // 9 // https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#c-cplusplus-language-support 10 // https://en.cppreference.com/w/cpp/preprocessor/replace#Predefined_macros 11 static_assert(__cplusplus >= 201402L, "expect C++ 2014 for nvcc"); 12 13 #include <fmt/core.h> 14 15 #include <cuda.h> 16 #include <iostream> 17 18 extern auto make_message_cpp() -> std::string; 19 extern auto make_message_cuda() -> std::string; 20 main()21int main() { 22 std::cout << make_message_cuda() << std::endl; 23 std::cout << make_message_cpp() << std::endl; 24 } 25 make_message_cuda()26auto make_message_cuda() -> std::string { 27 return fmt::format("nvcc compiler \t: __cplusplus == {}", __cplusplus); 28 } 29