A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/fmtlib/fmt/issues/4220 below:

MSVC warning - C4127: conditional expression is constant · Issue #4220 · fmtlib/fmt · GitHub

Seeing this on latest master.

minimal repro:

CMakeLists.txt

cmake_minimum_required(VERSION 3.20)
project(example)

add_executable(example main.cpp)

add_subdirectory(fmt)
target_link_libraries(example PRIVATE fmt)

target_compile_options(example PRIVATE "/WX" "/W4")

main.cpp

#include <fmt/format.h>

int main() {
    fmt::print("foo");
}
D:\src\example>cmake -S. -Bbuild -G"Visual Studio 17 2022"
-- The C compiler identification is MSVC 19.41.34123.0
-- The CXX compiler identification is MSVC 19.41.34123.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- {fmt} version: 11.0.2
-- Build type:
-- Configuring done (3.6s)
-- Generating done (0.1s)
-- Build files have been written to: D:/src/example/build

D:\src\example>cmake --build build
MSBuild version 17.11.9+a69bbaaf5 for .NET Framework

  1>Checking Build System
  Building Custom Rule D:/src/example/fmt/CMakeLists.txt
  format.cc
  os.cc
  Generating Code...
  fmt.vcxproj -> D:\src\example\build\fmt\Debug\fmtd.lib
  Building Custom Rule D:/src/example/CMakeLists.txt
  main.cpp
D:\src\example\fmt\include\fmt\format.h(1793,25): error C2220: the following warning is treated as an error [D:\src\example\build\example.vcxproj]
  (compiling source file '../main.cpp')

D:\src\example\fmt\include\fmt\format.h(1793,25): warning C4127: conditional expression is constant [D:\src\example\build\example.vcxproj]
  (compiling source file '../main.cpp')

D:\src\example\fmt\include\fmt\format.h(1816,7): warning C4127: conditional expression is constant [D:\src\example\build\example.vcxproj]
  (compiling source file '../main.cpp')

D:\src\example\fmt\include\fmt\base.h(2888,7): warning C4127: conditional expression is constant [D:\src\example\build\example.vcxproj]
  (compiling source file '../main.cpp')
      D:\src\example\fmt\include\fmt\base.h(2888,7):
      the template instantiation context (the oldest one first) is
          D:\src\example\main.cpp(4,10):
          see reference to function template instantiation 'void fmt::v11::print<>(fmt::v11::fstring<>)' being compiled

If this was coming while compiling format.cc then I wouldn't mind doing a target_compile_options(fmt ...) to disable the warning on fmt, but since this is happening in a header I get it in my own target too. I'd rather not have to disable this warning on my whole project or wrap every #include <fmt/format.h> with pragmas to disable it.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4