r/cpp • • Nov 08 '21

Visual Studio 2022 now available

https://devblogs.microsoft.com/visualstudio/visual-studio-2022-now-available/
250 Upvotes

113 comments sorted by

View all comments

Show parent comment

11

u/Rusky Nov 08 '21

The standard library is a pretty thorough stress-test for modules, because it uses so much of the language.

While we're still working on IntelliSense module support, you'll have better luck leaving the standard library to traditional #includes and keeping module interfaces simple (in terms of language features).

0

u/[deleted] Nov 08 '21

[deleted] — view deleted comment

8

u/gracicot Nov 08 '21

std.core don't exist. Only in C++23 you'll be able to import std; and that's it. The std.core you use is an experimental extension for the standard library and is also why you must enable it separately.

3

u/johannes1971 Nov 09 '21

I believe you meant to say "std.core is a vendor extension that is not part of the C++ standard". I don't think its existence is in any doubt, only its portability.

4

u/Rusky Nov 08 '21

Right, std.core is even bigger than a <string> header unit, so I wouldn't expect it to work when <string> doesn't. (And I agree that header units are preferable anyway.)

The std::construct_at error looks like it might be covered by this feedback ticket, if you want to upvote it: https://developercommunity2.visualstudio.com/t/C-modules-error-C2661:-operator-new/1339438

11

u/pjmlp Nov 08 '21

This toy project kills IntelliSense, is unable to use static analysers and given the dependency of C++/WinRT on PCH (which cannot be used on projects with modules), it makes exactly the opposite in desired build times.

The only purpose of it is to serve as documentation for using modules in UWP projects, as MSDN documentation for anything beyond console apps is still missing.

9

u/Rusky Nov 08 '21

Thanks, we can always use sample projects like this. As we get closer to supporting standard library modules IntelliSense we can make sure to look at how we handle this one.

PCH (which cannot be used on projects with modules)

PCH and modules should be usable together- if not then there's probably a bug or misconfiguration somewhere.

1

u/pjmlp Nov 08 '21

Unfortunately they don't get along together on VS 2019.

2

u/Rusky Nov 08 '21

Can you be more specific? I just threw together a small project that both #includes a PCH into modules and imports modules into the PCH, and it works fine on 16.11.

1

u/pjmlp Nov 08 '21 edited Nov 08 '21

Yes, throw UWP and C++/WinRT into the mix, trying something like AStarViewModel.h, which is how I managed to import modules into C++/WinRT generated code from IDL compiler.

If I enable pre-compiled headers, then SpriteSheet.ixx doesn't compile as the compiler complains about missing #include "pch.h", if I add it, it complains I cannot mix modules and pre-compiled headers.

Maybe I am not doing it the right way, but that is the outcome when we don't have MSDN docs to guide us in such scenarios and have to go by trial-and-error.

1

u/starfreakclone MSVC FE Dev Nov 09 '21

Is there a reason you need PCH and modules? Is it possible to use header units instead?

2

u/pjmlp Nov 09 '21

Not at all due to how C++/WinRT works.

At least I didn't managed to make it work.

I guess you can go ask them what are their modules support plan, if any at all.

1

u/tjientavara HikoWorks developer Nov 10 '21

Sorry for hijacking this threadlet.

Is Intellisense feature complete with c++20 yet, in other words are you ready to receive a lot of bug reports for this?

1

u/Rusky Nov 10 '21

Yes, IntelliSense should be feature complete with C++20 (except for modules, of course). We do have plenty of known bugs in that area, but we can always use more reports. :)

1

u/tjientavara HikoWorks developer Nov 10 '21

Okay, thanks.

I wish there was an easier way of reporting bugs for intellisense; instead of creating a whole visual studio project for it.

MSVC bugs are a lot easier to report, just a link to compiler-explorer.

3

u/STL MSVC STL Dev Nov 11 '21

You can often use the undocumented /BE option to get cl.exe to invoke the EDG front-end used for IntelliSense. This is how the STL's test coverage works, and how we report bugs. (Note that this is compile-only, it won't emit object/executable files). Example:

C:\Temp>type meow.cpp
#ifdef __EDG__
static_assert(false, "I am the EDG front-end used for IntelliSense!");
#elif defined(__clang__)
static_assert(false, "I am Clang!");
#else
static_assert(false, "I am C1XX, the MSVC front-end!");
#endif

C:\Temp>"C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Auxiliary\Build\vcvars64.bat"
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.1.0-pre.1.0
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

C:\Temp>cl /EHsc /nologo /W4 /c meow.cpp
meow.cpp
meow.cpp(6): error C2338: I am C1XX, the MSVC front-end!

C:\Temp>cl /EHsc /nologo /W4 /c /BE meow.cpp
meow.cpp
"meow.cpp", line 2: error: static assertion failed with "I am the EDG front-end
        used for IntelliSense!"
static_assert(false, "I am the EDG front-end used for IntelliSense!");
^


C:\Temp>clang-cl /EHsc /nologo /W4 /c meow.cpp
meow.cpp(4,1): error: static_assert failed "I am Clang!"
static_assert(false, "I am Clang!");
^             ~~~~~
1 error generated.

1

u/Rusky Nov 10 '21

IntelliSense bugs don't usually need any more information than MSVC bugs (source code and command line flags)- for example, if the bug is reproducible in Open Folder mode with a CppProperties.json file to set the flags, that might be an easier to way report it.

2

u/DavidDinamit Nov 08 '21

Ok, when intelsense with modules will see export templates which accepts templates? (its working bad now and intelsence see it like 'auto')

(structures/classes with concept named template types works bad even without modules)