
On Mon, 13 Jan 2025 at 20:37, Peter Dimov <pdimov@gmail.com> wrote:
Ruben Perez wrote:
I think this applies for non module units, too. I've just tested that, under MSVC, the following errors:
// File: main.cpp import std; #include <cstddef> int main() {}
This does not seem to happen with all the headers, though. * version, cstdint, climits, cassert, cfloat, cstdio, cstdlib, cerrno seem to work fine * cmath and cstddef seem to error.
So if we have in a program:
// File: main.cpp #include <boost/mp11.hpp> #include <boost/charconv.hpp> int main() {}
Yeah, that's going to be a problem.
Interestingly, though,
import std; #include <math.h> #include <stddef.h> int main() {}
works fine.
If we only need these for the macros, this might well work.
(It's probably std::byte from cstddef that breaks things.)
I think it has to do with where entities are declared. Your snippet errors if you import std.compat (which can safely be avoided altogether in all our code without problems): import std.compat; #include <math.h> #include <stddef.h> int main() {} [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(399): error C2995: 'bool isfinite(_Ty) noexcept': function template has already been defined [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(399): note: see declaration of 'isfinite' [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(405): error C2995: 'bool isinf(_Ty) noexcept': function template has already been defined [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(405): note: see declaration of 'isinf' [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(411): error C2995: 'bool isnan(_Ty) noexcept': function template has already been defined [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(411): note: see declaration of 'isnan' [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(417): error C2995: 'bool isnormal(_Ty) noexcept': function template has already been defined [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(417): note: see declaration of 'isnormal' [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(423): error C2995: 'bool isgreater(_Ty1,_Ty2) noexcept': function template has already been defined [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(423): note: see declaration of 'isgreater' [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(429): error C2995: 'bool isgreaterequal(_Ty1,_Ty2) noexcept': function template has already been defined [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(429): note: see declaration of 'isgreaterequal' [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(435): error C2995: 'bool isless(_Ty1,_Ty2) noexcept': function template has already been defined [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(435): note: see declaration of 'isless' [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(441): error C2995: 'bool islessequal(_Ty1,_Ty2) noexcept': function template has already been defined [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(441): note: see declaration of 'islessequal' [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(447): error C2995: 'bool islessgreater(_Ty1,_Ty2) noexcept': function template has already been defined [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(447): note: see declaration of 'islessgreater' [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(453): error C2995: 'bool isunordered(_Ty1,_Ty2) noexcept': function template has already been defined [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(453): note: see declaration of 'isunordered'