Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project using argparse won't compile using clang-cl #136

Closed
HFDan opened this issue Sep 29, 2021 · 4 comments
Closed

Project using argparse won't compile using clang-cl #136

HFDan opened this issue Sep 29, 2021 · 4 comments

Comments

@HFDan
Copy link

HFDan commented Sep 29, 2021

Relevant info:

  • IDE: Visual Studio 2022 Preview 4
  • OS: Windows 10 21H1 (Build 19043.1237)
  • Build System: CMake
  • Compiler: clang-cl
  • CXX Standard: C++17

Errors

PROJECT_DIR\lib\thirdparty\argparse\include\argparse\argparse.hpp(242,28): error : constexpr variable 'generic_strtod<float>' must be initialized by a constant expression
  template <> constexpr auto generic_strtod<float> = strtof;
                             ^                       ~~~~~~
PROJECT_DIR\lib\thirdparty\argparse\include\argparse\argparse.hpp(243,28): error : constexpr variable 'generic_strtod<double>' must be initialized by a constant expression
  template <> constexpr auto generic_strtod<double> = strtod;
                             ^                        ~~~~~~
PROJECT_DIR\lib\thirdparty\argparse\include\argparse\argparse.hpp(244,28): error : constexpr variable 'generic_strtod<long double>' must be initialized by a constant expression
  template <> constexpr auto generic_strtod<long double> = strtold;
                             ^                             ~~~~~~~

Build command (Ran by VS)

clang-cl.exe  /nologo -TP  -IC:PROJECT_DIR\lib\thirdparty\argparse\include -m64 -fdiagnostics-absolute-paths  /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MDd -std:c++17 /showIncludes /Fosrc\CMakeFiles\todo.dir\main.cpp.obj /Fdsrc\CMakeFiles\todo.dir\ -c -- PROJECT_DIR\src\main.cpp

CMakeLists.txt (@ Project root)

cmake_minimum_required (VERSION 3.16)
project ("PROJECT_NAME")
set(CMAKE_CXX_STANDARD 17)

add_subdirectory(src)
add_subdirectory(lib/thirdparty/argparse)

CMakeLists.txt (@ Project root/src/)

add_executable (executable_name "main.cpp")
target_include_directories(executable_name PRIVATE "${CMAKE_SOURCE_DIR}/lib/thirdparty/argparse/include/")
@HFDan
Copy link
Author

HFDan commented Sep 29, 2021

Clarification:
It compiles fine with msvc

@ghost
Copy link

ghost commented Nov 18, 2021

does -std:c++17 work in clang-cl? or should it be /std:c++17 ? I don't actually know anything about clang-cl, so i could be off base.

@HFDan
Copy link
Author

HFDan commented Nov 19, 2021

cl and clang-cl allow both / arguments and - arguments

@marstaik
Copy link

I just ran into this issue today as well, Im trying to figure out how to correct it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants