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

fmtlib does not compile with MSVC v140 #4346

Closed
csandmann opened this issue Feb 6, 2025 · 6 comments
Closed

fmtlib does not compile with MSVC v140 #4346

csandmann opened this issue Feb 6, 2025 · 6 comments
Labels

Comments

@csandmann
Copy link

Issue

The MSVC v140 build breaks with the attached errors.

format.cc
fmt\include\fmt\base.h(743): error C2327: 'fmt::v11::basic_specs::data_': is not a type name, static, or enumerator [fmt\build\fmt.vcxproj]
fmt\include\fmt\base.h(743): error C2065: 'data_': undeclared identifier [fmt\build\fmt.vcxproj]
fmt\include\fmt\base.h(743): error C2338:  [fmt\build\fmt.vcxproj]

System

Visual Studio 2022 (17.12.4) with MSVC v140 - VS 2015 C++-Buildtools (v14.00)

Details

  • Latest visual studio toolchain (v1942) builds without issues

Steps to reproduce

  1. git checkout v1.15.1
  2. cmake -T v140 -S . -B build/ && cmake --build build/
@sergiud
Copy link
Contributor

sergiud commented Feb 6, 2025

Even if one fixes this issue there's still a ton of different seemingly unrelated compile errors starting with the 11.1.x release series. Bisecting leads to 761d35f as the first bad commit.

@vitaut
Copy link
Contributor

vitaut commented Feb 7, 2025

This looks like a bug in specific compiler version considering that data_ is defined in

unsigned data_ = 1 << fill_size_shift;

and it works on other versions of the same compiler. I recommend updating to a newer compiler version, e.g. v141 which is known to work: https://github.com/fmtlib/fmt/actions/runs/13189537160/job/36820689152. If there is an easy workaround, a PR would be welcome too.

@vitaut vitaut closed this as completed Feb 7, 2025
@vitaut vitaut added the question label Feb 7, 2025
@edo9300
Copy link
Contributor

edo9300 commented Feb 7, 2025

A simple workaround could be to skip that static assert on msvc, since it will always be true

@vitaut
Copy link
Contributor

vitaut commented Feb 9, 2025

I think it's fine to remove the static assert if it helps (a PR is welcome), it doesn't add much value anyway.

@sergiud
Copy link
Contributor

sergiud commented Feb 9, 2025

No need to remove the static_assert. Qualifying the member is sufficient:

diff --git a/include/fmt/base.h b/include/fmt/base.h
index 8fdcea7c..ce71ad98 100644
--- a/include/fmt/base.h
+++ b/include/fmt/base.h
@@ -740,7 +740,7 @@ class basic_specs {
   };
 
   unsigned data_ = 1 << fill_size_shift;
-  static_assert(sizeof(data_) * CHAR_BIT >= 18, "");
+  static_assert(sizeof(basic_specs::data_) * CHAR_BIT >= 18, "");
 
   // Character (code unit) type is erased to prevent template bloat.
   char fill_data_[max_fill_size] = {' '};

As previously mentioned, however, this does not fix the compilation errors using the vc140 toolset because more errors arise after a fix.

@vitaut
Copy link
Contributor

vitaut commented Feb 12, 2025

v140 is pretty old and we don't claim compatibility with it. But as I wrote earlier, if there is an easy fix, a PR would be welcome.

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

No branches or pull requests

4 participants