biojppm / rapidyaml

Rapid YAML - a library to parse and emit YAML, and do it fast.
MIT License
568 stars 97 forks source link

fix: add /Zc:__cplusplus for correct __cplusplus value in MSVC #444

Closed linuslau closed 3 months ago

linuslau commented 3 months ago

When compiling with C++17 in MSVC (VS2022), error C2039: 'chars_format': is not a member of 'std' occurs. This is due to the __cplusplus macro always being set to 199711L, regardless of the specified C++ standard. Consequently, conditionally included headers such as are not included.

Adding the /Zc:cplusplus option ensures the cplusplus macro reflects the correct C++ standard. Please consider this change.

biojppm commented 3 months ago

Thanks for the PR.

However, even if #445 is legitimate (let's discuss there), using a cmake option is not the proper way to go about it. Also, given that the (possible) error is in c4core, any fix must be in c4core, and not in this repo.

FYI, MSVC has the macro _MSVC_LANG which is defined to the proper value, and that is already handled in c4/language.hpp. At best, this macro would be used in the problematic place at charconv.hpp. Which, again, is a fix in c4core, not in this repo.

biojppm commented 3 months ago

The fix to #445 was done in the c4core repo. See https://github.com/biojppm/c4core/commit/f4da68855bcb3015ec20c0c2f37180be90b7d268.

Thanks again for the PR, but it does not address the underlying problem. Closing now.