cuda-cpp14.cu 905 B

12345678910111213141516171819202122232425262728
  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. // Ensure that we are using the latest C++ standard for NVCC
  6. // The version is C++14
  7. //
  8. // https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#c-cplusplus-language-support
  9. // https://en.cppreference.com/w/cpp/preprocessor/replace#Predefined_macros
  10. static_assert(__cplusplus >= 201402L, "expect C++ 2014 for nvcc");
  11. #include <fmt/core.h>
  12. #include <cuda.h>
  13. #include <iostream>
  14. extern auto make_message_cpp() -> std::string;
  15. extern auto make_message_cuda() -> std::string;
  16. int main() {
  17. std::cout << make_message_cuda() << std::endl;
  18. std::cout << make_message_cpp() << std::endl;
  19. }
  20. auto make_message_cuda() -> std::string {
  21. return fmt::format("nvcc compiler \t: __cplusplus == {}", __cplusplus);
  22. }