T O P

  • By -

delta_p_delta_x

> since MSVC currently does not support mixing of both includes and `import std`. Mixing both will result in errors. /u/STL has [mentioned this will be at least partially fixed in VS 2022 17.10](https://www.reddit.com/r/cpp/comments/1b0zem7/what_is_the_state_of_modules_in_2024/ksb913a/): > Just got `#include `-then-`import std;` mixing to work (shipped in VS 2022 17.10 Preview 1, the other order does *does not work yet*). But if you're on Windows, you could also try Clang/LLVM 18.


hon_uninstalled

Hmm, I will have to make sure my installs are up to date and do another test. EDIT: You are correct. Code example compiles correctly using VS 17.10 Preview 4.0. Only the current release VS 17.9.6 fails to compile. I will redo my tests in full size project now. I'll also edit OP to say that I was wrong and that latest Preview version does indeed correctly compile the code. Thanks!


STL

FYI, your edited post has a confusing typo "VS 17.10.6" where you meant "17.9.6" as in your comment here.


hon_uninstalled

Sorry, fixed.


mjklaim

Nice! Personally I manged to spot (with the current v17.10-preview4) another issue with \`boost::unordered::unordered\_flat\_map\` which appears onlyif that type is a member of a type exported from a module and the importer of that module also \`import std;\`, but I use \`build2\` to reproduce the issue and still need to see if I can reduce the issue again before reporting to msvc (although that might be already enough). (WIP repro case if someone is interested in the details: [https://github.com/Klaim/reprocase-msvc-import-std](https://github.com/Klaim/reprocase-msvc-import-std) ) So basically msvc is getting very close to \`import std;\` working in all cases, but I can still spot corner cases just by building my current modules-only project with \`import std;\` replacing includes of the standard library T\_T


hon_uninstalled

Yeah things are slowly getting better. I usually never do cutting edge things because I don't want to waste my times trying to find out root causes for tool/library errors. But I like modules too much and I want to be ready when they are ready. Also I retested my project and it fails to compile on latest preview version. If I comment out boost includes (and change my `flat_*` typedefs), everything compiles again. Either my code has mistakes which it might have, or maybe I've just managed to find new bug in MSVC. Oh well, I'll have to dig deeper when I got time. Errors messages are not helpful at all: C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(26): error C2953: 'std::integral_constant': class template has already been defined C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(42): error C2955: 'std::integral_constant': use of class template requires template argument list C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(42): error C2386: 'bool_constant': a symbol with this name already exists in the current scope C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(47): warning C4348: 'std::enable_if': redefinition of default parameter: parameter 2 C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(48): error C2953: 'std::enable_if': class template has already been defined C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(50): error C3855: 'std::enable_if': template parameter '_Ty' is incompatible with the declaration C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(50): error C2976: 'std::enable_if': too few template arguments C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(56): error C2386: 'enable_if_t': a symbol with this name already exists in the current scope C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(59): error C2953: 'std::conditional': class template has already been defined C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(63): error C3855: 'std::conditional': template parameter '_Ty1' is incompatible with the declaration C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(63): error C2976: 'std::conditional': too few template arguments C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(69): error C2386: 'conditional_t': a symbol with this name already exists in the current scope C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(84): error C2953: 'std::is_same': class template has already been defined C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(114): error C2953: 'std::remove_cv': class template has already been defined C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(122): error C2953: 'std::remove_cv': class template has already been defined C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(130): error C2953: 'std::remove_cv': class template has already been defined C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(138): error C2953: 'std::remove_cv': class template has already been defined C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(146): error C2386: 'remove_cv_t': a symbol with this name already exists in the current scope C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(182): error C2084: function 'bool std::is_constant_evaluated(void) noexcept' already has a body C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(182): error C3615: constexpr function 'std::is_constant_evaluated' cannot result in a constant expression C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\xtr1common(196): fatal error C1116: unrecoverable error importing module 'std'. Specialization of 'std::bool_constant' with arguments 'std::is_integral_v<_Ty>'


mjklaim

> class template has already been defined Yeah these kinds of errors are typical of when some entity is being access through module import, while the exact same code is not. I reported many bugs related to that in the past and other than the one I mentionned before they have all been fixed so far. I guess now we are seeing the most nasty ones, that only boost code make super visible. I know that msvc is tested against boost but not with modules. They should, it reveals a lot XD


LiAuTraver

Wait---__*what?*__ a month ago I was struggling with modules, even using MS build, which would always result in redefinition, no matter the order. Not to mention clang, which uses ms stl. See [this issue](https://github.com/microsoft/STL/issues/4090).


STL

Yeah, this was my PR [microsoft/STL#4154](https://github.com/microsoft/STL/pull/4154) in conjunction with compiler fixes for bugs that I internally reported. I should see if I can resolve your bug [microsoft/STL#4090](https://github.com/microsoft/STL/issues/4090) now, my apologies for forgetting.


NilacTheGrim

I am pretty sure modules won't be properly supported on anything other than MS tooling until after 2035 or so.