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

Compile error in format-inl.h when including FMT using CMake's FetchContent on Windows #2808

Closed
szymonj99 opened this issue Mar 11, 2022 · 3 comments

Comments

@szymonj99
Copy link

szymonj99 commented Mar 11, 2022

I'm using CMake and using GitHub Actions to compile the code remotely. I'm getting the same compile error locally.

Using this commit: a8fe8be

I like to think the options below might be of use (e.g. The C++ standard I'm using.) 🚀

CMakeLists.txt

...
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory(src)

src/CMakeLists.txt

...
FetchContent_Declare(fmt
  GIT_REPOSITORY https://github.com/fmtlib/fmt.git
  GIT_TAG a8fe8becf45b520c03250bda6e6914786ee91d83
)
FetchContent_MakeAvailable(... fmt ...)
...
set(BUILD_SHARED_LIBS OFF)
...
set(SPDLOG_FMT_EXTERNAL_HO ON)
set(SPDLOG_FMT_EXTERNAL OFF)
...
target_link_libraries(${PROJECT_NAME} PRIVATE ... fmt::fmt-header-only ...)
...
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
...

Error log

...\build\_deps\fmt-src\include\fmt\format-inl.h(1823,44): warning C4003: not enough arguments for function-like macro invocation 'max'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1823,44): error C2589: '(': illegal token on right side of '::'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1823): error C2062: type 'unknown-type' unexpected
...\build\_deps\fmt-src\include\fmt\format-inl.h(1823,55): error C2059: syntax error: ')'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1828,43): warning C4003: not enough arguments for function-like macro invocation 'max'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1828,43): error C2589: '(': illegal token on right side of '::'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1828): error C2062: type 'unknown-type' unexpected
...\build\_deps\fmt-src\include\fmt\format-inl.h(1828,53): error C2059: syntax error: ')'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1828,55): error C2143: syntax error: missing ';' before '{'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1855,46): warning C4003: not enough arguments for function-like macro invocation 'max'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1855,46): error C2589: '(': illegal token on right side of '::'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1855): error C2062: type 'unknown-type' unexpected
...\build\_deps\fmt-src\include\fmt\format-inl.h(1855,57): error C2059: syntax error: ')'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1860,45): warning C4003: not enough arguments for function-like macro invocation 'max'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1860,45): error C2589: '(': illegal token on right side of '::'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1860): error C2062: type 'unknown-type' unexpected
...\build\_deps\fmt-src\include\fmt\format-inl.h(1860,55): error C2059: syntax error: ')'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1860,57): error C2143: syntax error: missing ';' before '{'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1876,44): warning C4003: not enough arguments for function-like macro invocation 'max'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1876,44): error C2589: '(': illegal token on right side of '::'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1876): error C2062: type 'unknown-type' unexpected
...\build\_deps\fmt-src\include\fmt\format-inl.h(1876,55): error C2059: syntax error: ')'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1881,43): warning C4003: not enough arguments for function-like macro invocation 'max'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1881,43): error C2589: '(': illegal token on right side of '::'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1881): error C2062: type 'unknown-type' unexpected
...\build\_deps\fmt-src\include\fmt\format-inl.h(1881,53): error C2059: syntax error: ')'
...\build\_deps\fmt-src\include\fmt\format-inl.h(1881,55): error C2143: syntax error: missing ';' before '{'

I wonder if this is a configuration issue instead, or something to do with me including additional dependencies 🤔

@vitaut
Copy link
Contributor

vitaut commented Mar 12, 2022

The max issue should be worked around in 9a1beab.

@szymonj99
Copy link
Author

Can confirm, the commit above fixed the issue. 💯

@vitaut
Copy link
Contributor

vitaut commented Mar 12, 2022

Thanks for reporting and checking the fix!

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

No branches or pull requests

2 participants