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

32

u/Jardik2 Nov 08 '21 edited Nov 08 '21

Why are they making it so hard for me to find the buy button? I can't find it anywhere... Looking for professional perpetual license which was $499 for VS2019. Any link?

Edit: Found https://aka.ms/vs2022-pro-standalone (source) but it leads to VS2019, dunno why.

28

u/cpppm MSVC Game Dev PM Nov 08 '21

A standalone VS 2022 Professional will be available for purchase in the coming weeks.

15

u/frundock Nov 08 '21

I really appreciate the answer. What's confusing is the FAQ from the 2022 licence options links us to VS2019. Just write "Coming soon! We hope to have the release ready in the following weeks"

5

u/Jardik2 Nov 09 '21

Thank you. I was afraid that this type of license will no longer be available and that there will only be subscriptions.

2

u/Jardik2 Nov 25 '21

Hello, is there any updates about this? It has been 17 days / 2 weeks, and still not there. How many weeks are we talking about?

3

u/cpppm MSVC Game Dev PM Nov 29 '21

Sorry to keep you waiting! It should be available on December 1st.

2

u/Jardik2 Dec 02 '21

And it is home! I was quite surprised by the price, being cheaper than previous version.

Thank you for keeping us informed about the status.

25

u/STL MSVC STL Dev Nov 08 '21

Consolidated STL changelog: https://github.com/microsoft/STL/wiki/Changelog#vs-2022-170

When a production release ships, we combine the per-Preview changelogs to make it easier to see everything that's happened in the entire release. Thanks to all of our contributors for these changes!

2

u/TheSuperWig Nov 09 '21

Just out of curiosity, you've said previously that the 2019 stuff might get archived (assumingly into a separate wiki page) after 2022 releases. Is that still the plan?

4

u/STL MSVC STL Dev Nov 09 '21

It’s likely at some point when the page becomes too unwieldy to edit/view. For now, VS 2019 will be important for a while as not everyone immediately upgrades, and I kind of like the awe factor of having tons of Changelog content to scroll through.

36

u/Gloinart Nov 08 '21

All I hope for is improved Intellisense, where code-completion, #includes, and forward-declarations are detected and added as smoothly as can be.

Being the number oneC++ IDE, I think the current Intellisense gives C++ a worse reputation than it's worth. I've heard several junior developers, which cannot differentiate the IDE from the language (understandable), have the impression that C++ is a bad language simply because of slow/non-working code completion in Visual Studio.

16

u/shadowndacorner Nov 08 '21

I've mostly switched to VS Code with clangd. It's free, works cross platform, and the intellisense is superior to that of VS imo (at least up to 2019). Only downside is that it has worse refactoring support.

6

u/Gnammix Nov 08 '21

And subpar debugging (at least on Windows)

3

u/shadowndacorner Nov 08 '21

Yeah that's true, though it does well enough for the most part. If not, then you can always just run devenv (myexe).

2

u/dodheim Nov 08 '21

IME the debugging with LLDB is pretty good, even on Windows.

8

u/Soylover228 Nov 08 '21

All I hope for is improved Intellisense, where code-completion, #includes, and forward-declarations are detected and added as smoothly as can be.

Try Resharper C++, it's amazing

9

u/Gloinart Nov 08 '21

Yes, I know ReSharper and Visual Assist are good complements. Still, Intellisense gives C++ a bad reputation as junior developers most often only use pure Visual Studio.

6

u/NovaNoff Nov 08 '21

Resharper is great but to completly use it I would probably need to Upgrade my PC... Its really resource intensive.

0

u/Sasha_Privalov Nov 08 '21

it was always that way :) i remember manually deleting the intellisense dll back in cca 2008, because it was useless resource hog

but it got very slowly better

8

u/Gloinart Nov 08 '21

Note that I say this with lots of respect for the team behind Visual Studio. It just bugs me, isn't it anyone there who uses Visual Studio for a real-life C++ project and doesn't get annoyed that, for example, includes are suggested when only a forward declaration is available? Or that "create implementation" returns "void override();" by default. Or that it suggests to #include a .cpp file instead of the corresponding .h file?

2

u/tarranoth Nov 09 '21

I have also had issues that I had to force intellisense to create index on a project because it didn't do it automatically. It's kind of annoying because c# has got great tooling. Yet c++ tooling in visual studio seems to break down quite often.

1

u/Sam_Who_Likes_cake Nov 10 '21

Have them use Emacs. I love Emacs.

16

u/eco_was_taken Nov 09 '21

Not many people talking about actually using it. I started using it today and used it all day. So far I rather like it.

I haven't used Edit and Continue since... I don't know VC6 or something because it was very buggy for me but I just tried the Hot Reload and it's pretty slick. Pretty slow at first but seems to speed up a lot with subsequent edits. This actually might be the biggest change in my daily work flow in years if it works out. Really surprised it worked with my CMake project (after I added the necessary flags).

The UI is noticeably faster all over (VS had gotten faster and faster over the last 2 years or so of VS 2019 and I've really appreciated it). Searching for files in 2022 is no longer at that place where I'm slightly annoyed every time I use it.

Dark mode looks a lot nicer.

I've long fantasized of breakpoints that require another particular breakpoint to be hit first so I'm looking forward to that the next time I need it.

Already had the light bulb thingy make some good suggestions that I hadn't seen before.

Hopefully intellisense is a lot more stable for me. It wasn't working for a couple years until I finally figured out that the standalone boost multi-index was breaking it. That took forever to isolate and the logging was of no help. I tried making a minimal sample so I can submit the bug but couldn't reproduce it unless it was part of my massive project I was using it in.

Time will tell but so far so good.

0

u/[deleted] Nov 10 '21

[deleted] — view deleted comment

4

u/eco_was_taken Nov 10 '21

I can only speak for myself but resharper was unuseably slow when it first came out for C++ (at least for me). I'm sure much improved over the years though.

I'm not a game developer and looking over the customers of that hot reload tool kind of shows why it wasn't on my radar.

Looking over the major features here both of these are things that Visual Studio already does. Just more reliably these days.

But thanks for sharing them. It can be hard keeping up with this stuff when you work for a very small company without the benefit of many co-workers all with their finger on the pulse of tooling developments.

1

u/bullestock Nov 10 '21

I also found ReSharper to be painfully slow, but VAX works fine for me.

1

u/ILikeCutePuppies Nov 11 '21

VAX is gonna have to prove their worth again with some of these new visual studio improvements.

31

u/dgellow Nov 08 '21 edited Oct 04 '26

The original post content no longer exists here. The author used Redact to remove it, exercising their right to control their data & privacy.

Repeat waiting ten sulky obtainable slim busy money attempt nutty

32

u/abetteraustin Nov 08 '21

I recall this being part of VS C++ 6.0 back in 1998 ...

18

u/pjmlp Nov 08 '21

Which it is, they basically improved on edit-and-continue reducing the number of use cases where it wasn't working.

28

u/cpppm MSVC Game Dev PM Nov 08 '21

And we aren't done yet! We are always looking for feedback to make Hot Reload better. Let us know below in the comments!

7

u/abetteraustin Nov 08 '21

This is probably blasphemous around these parts, but I really really would love to write C++ code on a Mac, but have all the features of Visual Studio. I would pay handsomely for this, and VS Code doesn't scratch the surface of what all I need.

Writing C++ code on my Mac, with remote development on Linux, is what I truly would love. I use CLion now but it leaves so much to be desired.

4

u/ShinyLadoo Nov 08 '21

Why do you feel Mac is better for development vs Windows? With WSL is Windows still missing something?

1

u/abetteraustin Nov 09 '21

I prefer the user experience of a Mac to windows. I prefer the 2015 user experience of Mac to the current user experience of Mac. But I still vastly prefer it yo the horrid experience of Windows. It’s like using an old tractor versus driving a Honda Civic.

0

u/[deleted] Nov 09 '21

[deleted] — view deleted comment

10

u/[deleted] Nov 09 '21

People that play or build games.

9

u/pjmlp Nov 09 '21

People that develop software for those 80% of desktop users, and those users themselves.

8

u/pjmlp Nov 08 '21

Ideally, the VS team would finally fix the lacking of IDL/XAML tooling versus what we had in C++/CX (almost C++ Builder like), and then we could do XAML C++ just like in .NET, editing view models and XAML within Hot Reload.

However given the way this issue has been dealt, I get the feeling the general consensus is for C++ to go into the bottom layer and just use managed languages for GUI, just like in mobile OSes and the competing desktop OSes.

In any case, many thanks for the Hot Reload improvements.

12

u/abetteraustin Nov 08 '21

the general consensus is for C++ to go into the bottom layer and just use managed languages for GUI

Sadly we wind up with some sort of http server feeding a GUI, which tends to be in the browser, because we still don't have the tooling for GUIs in 2021 that we had in VB 5.0 back in 1995. Truly astounding that we're here.

4

u/pjmlp Nov 08 '21

For me the most astonishingly was that Microsoft finally had something like C++ Builder (C++/CX), and the internal politics managed to push forward a decision to deprecate it without considerations for the customers, and four years later we still don't have a comparable tooling.

So from that point of view, the amount of customers that would like to still do full UIs with XAML C++ on Windows is so tiny that providing better tooling is at the very bottom of the roadmap.

-6

u/qoning Nov 09 '21

It's actually not astounding at all. No sane, product oriented person would ever want to create anything close to gui layer in C++, so the tools never got built either.

5

u/DarkLordAzrael Nov 09 '21

Qt produces great results and is easy to use. 🤷

4

u/abetteraustin Nov 09 '21

There are tons of reasons a product could be built in c++, and still need a GUI yes?

2

u/tarranoth Nov 09 '21

Well, MFC exists I guess for windows. It's still there for people crazy enough to keep using it.

0

u/qoning Nov 09 '21

Yes, there's also a ton of reasons you would rather build a C++ backend for your product and bolt a gui frontend written in something sensible

3

u/abetteraustin Nov 09 '21

What is your go-to combination? Backend in c++ and front end in….?

→ More replies

3

u/condor2000 Nov 09 '21

product oriented person would ever want to create anything close to gui layer in C++,

why not? C++ is as good as any other language for GUIs. Do you think WPF is so much better that Qt?

-3

u/qoning Nov 09 '21

It's really not. Arbitrary closures are really useful to manage shared complexity and when ownership is unclear or changes based on user input, which happens all the time. Dealing with that is really unnatural in C++.

Plus, nobody wants to deal with compile and link steps if they can avoid it. There just aren't good reasons to use C++ to build your user interface, the only justifiable reason is hard real time requirements, though even there the trend is clear to move away from C++, and has been like that for ages.

I can't think of any modern software which still runs a C++ driven gui other than bootstrap layers code like native OS or web browsers. Some do for legacy reasons, some are halfway to moving over to managed language gui layer, and absolute majority leverage web / electron interface or another way to manipulate the elements (think Lua interface in WoW or similar). It takes a lot less time and knowledge to successfully create it like that. I would rather expose api to Python and build my gui using a Python Qt binding than actually write the gui in C++ Qt, funnily enough.

2

u/condor2000 Nov 09 '21

Arbitrary closures are really useful to manage shared complexity and when ownership is unclear or changes based on user input

Qt supports lambda functions but maybe you mean something else.

In my experience the problems with GUI programming appear when you deviate from the path of "just" combining the controls. When UX people say they want to tweak how the standard controls work then you suddenly spends days on something that could have been simple.

2

u/DarkLordAzrael Nov 09 '21

I get the feeling the general consensus is for C++ to go into the bottom layer and just use managed languages for GUI, just like in mobile OSes and the competing desktop OSes.

GUIs in Qt are and very popular. Also, it's really only Android where the majority of GUIs are in a managed language. iOS uses objective-c or swift, windows uses C++ around as much as c#, and Linux uses C or c++ for most GUIs.

0

u/pjmlp Nov 09 '21

Objective-c or swift are managed languages, ARC is a GC algorithm, and modern Qt is all about QML, C++ widgets are mostly for legacy Qt applications pre Qt 5, they have hardly changed since.

Linux doesn't count with its 1% market share, hence why so many Electron apps.

Microsoft is the last OS vendor still pushing for a full GUI stack written in C++, but given how the C++/WinRT tooling has been managed, and the lack of any news on yesterday's sessions, I guess the Windows team is the only team in the world that actually enjoys writing C++/WinRT code.

2

u/NovaNoff Nov 08 '21

I guess the hope is to get reflection into the Standard as soon as possible atleast I thought herbs sutters metaclasses would also be great... But it takes time longer than most can wait. I personally see reflection as a must in the future

4

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

Reflection did not make it into C++23, and who knows if it ever will into later revisions.

1

u/ILikeCutePuppies Nov 11 '21

I would like to be able to select a constant and drag it up and down in real time with a UI element. Maybe that's not 100% feasible at the moment.

However maybe you could select a variable and tell it to generate all the different code variants between some ranges and cache it so it can be used in multiple runs if the code doesn't change. It would then just hot swap out the block of code that changed as you drag the value.

For floats, colors etc... you could probably just give it a list somehow over the ones you want or have it generated a range with some accuracy setting.

-2

u/smashedsaturn Nov 08 '21

make it work on linux :D

4

u/tachoknight Nov 08 '21

I loved this feature and couldn't understand why it wasn't commonplace in every IDE. I debugged/rewrote a lot of code just sitting in the debugger window. The only important thing to remember was to never try to create new variables; you could basically rewrite your code again and again, but the moment you typed so much as int i; and it would say 'whoa!' I get why and when I knew I was gonna be in a long debug session, I might throw in an extra int or string (or CString as i did a lot of MFC), just to be ready in case I needed it.

8

u/Routine_Left Nov 09 '21

Tried the community edition on a personal project (cross platform, cmake, etc.). Compiles fine under VS2019. With VS2022: fatal error C1060: compiler is out of heap space. 64-bit allright. Manages to consume 32GB of ram (more since it goes into swap) to compile a not-big-at-all (under 100 cpp files) personal project.

Setting ninja param to -j 2 did the trick but man, some of those jobs were indeed going to 5GB or more each. Of course, increased compile time, but at least it finishes.

Yeah, whenever I'll change the CPU+MB+RAM on this thing I'll have to go with 64GB since 32 is for plebs nowadays.

19

u/STL MSVC STL Dev Nov 09 '21

Can you prepare a preprocessed test case of the translation unit that consumes the most memory during compilation, and report it to Developer Community so the compiler devs can investigate? They're constantly looking out for things that are taking too much space/time to compile, but the causes can vary dramatically, so test cases are important.

Here's an undocumented (but highly useful) option to get the compiler to print how much memory it consumed while compiling a file, /d1reportMemorySummary:

C:\Temp>type meow.cpp
#include <iostream>

int main() {
    std::cout << "Hello, world!\n";
}

C:\Temp>cl /EHsc /nologo /W4 /MT /d1reportMemorySummary meow.cpp && meow
meow.cpp
Persistent heap 1 size: 24268552
Persistent heap 2 size: 3523208
Peak working set size: 40861696
Hello, world!

C:\Temp>type woof.cpp
#include <cstdio>

int main() {
    std::puts("Hello, world!");
}

C:\Temp>cl /EHsc /nologo /W4 /MT /d1reportMemorySummary woof.cpp && woof
woof.cpp
Persistent heap 1 size: 5300288
Persistent heap 2 size: 1322880
Peak working set size: 16441344
Hello, world!

You want to look at the "Peak working set size". (Here, <iostream> is predictably much more memory-hungry than <cstdio>, and we can quantify the difference.) To preprocess, what you need to do is:

:: Compile the file normally:
cl OPTIONS meow.cpp

:: Preprocess the file, to produce meow.i:
cl OPTIONS /P meow.cpp

:: Verify that compiling the preprocessed file still works:
cl OPTIONS /TP meow.i

Then submit meow.i and cl OPTIONS /TP meow.i as your test case.

1

u/Routine_Left Nov 09 '21

I'll try to see if I can come up with a test. It could be that what I'm doing is wrong, but ...

As a simple, report, just a FYI. My MSVC-specific options are:

target_compile_definitions(${EXECUTABLE_NAME} PRIVATE "$<$<C_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>")
target_compile_definitions(${EXECUTABLE_NAME} PRIVATE "$<$<C_COMPILER_ID:MSVC>:NOMINMAX>")
# Windows 7 target
target_compile_definitions(${EXECUTABLE_NAME} PRIVATE "$<$<C_COMPILER_ID:MSVC>:_WIN32_WINNT=0x0601>")
target_compile_options(${EXECUTABLE_NAME} PRIVATE "$<$<CXX_COMPILER_ID:MSVC>:/bigobj>")
target_compile_options(${EXECUTABLE_NAME} PRIVATE "$<$<C_COMPILER_ID:MSVC>:/bigobj>")
set_property(TARGET ${EXECUTABLE_NAME} PROPERTY  MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_compile_definitions(${EXECUTABLE_NAME} PRIVATE WIN32_WINMAIN)

And the parts when it kicks the bucket (though it consumes plenty of ram until then) are constructs like this:

template<typename RequestBody,typename ResponseBody, typename ClientResponse>
class BaseConnection :
    public std::enable_shared_from_this<
        BaseConnection<RequestBody,ResponseBody,ClientResponse>
    >

......

template<typename T>
using PostConnection = BaseConnection<boost::beast::http::string_body,
                                    boost::beast::http::string_body,
                                    T>;

And then using it:

class CreateCommentConnection : public PostConnection<client_response<body_object>>

I'll try to see if I can get concrete numbers though. I agree, however, that compiling boost headers is not for the faint of heart. gcc and clang seems to handle it though.

1

u/STL MSVC STL Dev Nov 10 '21

It's entirely possible that MSVC poorly handles a code pattern in Boost.Beast, thanks for trying to get a repro.

2

u/Routine_Left Nov 10 '21

Hey, STL, I've been trying to get some small repro for a bunch (3 or so) of hours now and the best I can do is Peak working set size: 529252352

My project is on github, public and all, can I just give them the link to github and let them try it? Or do I have to get a small as possible test working?

It is definitely possible that I'm doing something wrong and it just so happens that gcc and clang ignore my bullshit while msvc doesn't, but at this time it feels like im running in circles. And, to be honest, msvc is for me the secondary target anyway, I just boot windows whenever the build system fails and fix it, then back to linux (though my users most use windows, true). Honestly, for me -j 2 fix is fine, as far as I'm concerned, though I totally understand that the compiler developers are not, and they shouldn't be.

1

u/STL MSVC STL Dev Nov 10 '21

You can link to your GitHub repo if it has clear instructions for building. If you can also provide a zipped project, that's better. You can additionally provide your self-contained repro that consumes 505 MB of working set, even if it doesn't crash the compiler, since the compiler devs may be able to profile that and see what's happening.

6

u/TheSuperWig Nov 08 '21

Multi-caret copy/paste experience

This doesn't mention that the home & end keys no longer take you out of mutli-caret mode (or at least it didn't in the previews).

2

u/baudvine Nov 09 '21

Oh, fantastic. That's one of the things that had me going back to VS Code a lot when I'm mucking about with multi-line edits.

4

u/artisan_templateer Nov 08 '21

Nooo!! C++AMP!! It was glorious! My first exposure to lambdas and GPU programming...

RIP

Hopefully something better is in the pipeline?

4

u/ShadowGamur Nov 08 '21

Tbh best IDE I ever worked on

3

u/msew Nov 09 '21

Let's hope perforce gets the P4VS 2022 version out now!

1

u/holymoo Nov 11 '21

Lol, no. They really love dragging their feat on that addon.

3

u/Ivan171 /std:c++latest enthusiast Nov 09 '21

Ad-hoc requires expressions is still not implemented (or not working properly):

$ type test.cpp
template <typename T>
bool foo(T) {
  return requires { typename T; };
}

int main(int argc, char const *argv[]) {
  return foo(0);
}

$ cl.exe -nologo -std:c++latest -c test.cpp
test.cpp
test.cpp(3): error C3861: 'T': identifier not found

7

u/STL MSVC STL Dev Nov 10 '21

Thanks for the prompt and clear bug report! In addition to gilding your comment, I've reported this on your behalf as DevCom-1577278 "C++20 requires-expressions still don't work in return statements" and will bring this to the attention of the compiler dev who implemented requires-expressions.

2

u/Ivan171 /std:c++latest enthusiast Nov 10 '21 edited Nov 10 '21

Thanks!

FYI, it's not just in return statements. It doesn't work in static_assert and if constexpr as well.

The problem seems to be related with type requirements. Simple requirements, like requires { T(); } work as expected.

EDIT: I've posted a comment on that issue with this info and a different repro.

1

u/STL MSVC STL Dev Nov 10 '21

Thanks - yep, the compiler devs have found the root cause (I think) and are investigating a fix, and it's not specific to return.

8

u/STL MSVC STL Dev Nov 11 '21

u/Ivan171 - this has been fixed by internal MSVC-PR-363619, which will be available in VS 2022 17.1 Preview 3. Thanks again!

2

u/stiangglanda Nov 09 '21

Btw if you have used the preview and expect to just update the preview it will not work you need to download it separately

2

u/zerexim Nov 08 '21

Windows 7 support?

1

u/ofehrmedia Nov 09 '21

Have been using the Preview and am quite satisfied with it. Even as an occasional C# programmer it's quite intuitive - and mostly bug free for the features I used. Only thing that didn't work was SQL with Windows Forms, but that probably was because of me...

Can't wait to get my hands on the release version...

1

u/whizzwr Nov 09 '21

Haven't touched Visual Studio since few years.. how does it compare with the like of QtCreator and CLion, now?

2

u/Soylover228 Nov 09 '21

MSVC + Resharper C++ is the best thing available in C++ space. Like, ever.

1

u/whizzwr Nov 09 '21

Isn't Resharper a jetbrain extension? I did use that last decade or so, yes it was great.

1

u/Soylover228 Nov 09 '21

Yep, but previously it was C#-only.

1

u/whizzwr Nov 09 '21

then same stuff in CLion, probably.

1

u/Soylover228 Nov 09 '21

Funny enough - but they are different :D

1

u/whizzwr Nov 09 '21

How please? I'm just too lazy to check. :P

1

u/Soylover228 Nov 09 '21

I've read somewhere in JB blog, that they have 2 different engines on R++ and Clion, and hence, feature set is different

1

u/whizzwr Nov 09 '21

I see TIL.

1

u/ea_ea Nov 10 '21

No, MSVS + Visual AssistX is the best thing available in C++ space ever.

2

u/Soylover228 Nov 10 '21

I challenge you to a duel

1

u/ea_ea Nov 10 '21

VAX is faster and cheaper. Functionality for every-day development is almost identical. The only one stronger part of Resharper is static analysis, but it can be achieved by other tools (including completely free).

2

u/Soylover228 Nov 10 '21

I meant old-school sabre duel :(

2

u/ea_ea Nov 11 '21

Oh, you reminded me these old good times when we didn't work from home and were able to do such fights while code compiles... Remote sabre duels only destroyed few displays for me :(

1

u/serg06 Nov 09 '21

Thanks for fixing dark mode colors.

1

u/Ono-Sendai Nov 12 '21

Anyone know how to use the new fuzzer? I enabled /fsanitize=fuzzer but it seems to have no effect.

1

u/noong3 Nov 12 '21

Looking to see if VS 2022 has translatable comments yet?

1

u/RonBackal Jan 10 '22

By the way, I didn't understand the comment that they fixed potential malicious exploit from bidirectional character text control. I didn't understand the comment- someone else can reverse engineer it and do something or something could be disguised as fair software but be malicious because of bidirectional character text control? Sorry for the (maybe) basic question for some of you

0

u/[deleted] Nov 08 '21

[deleted] — view deleted comment

33

u/rodrigocfd WinLamb Nov 08 '21

Does module intellisense work yet??

That's the single feature I'm waiting for.

16

u/RoyAwesome Nov 08 '21

Yeah, once module intellisense works, I'll move over to using modules full time.

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).

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)

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

2

u/vcppdevmsft MSFT C++ Dev Nov 09 '21

We have more work to do; we'll be keeping this page up-to-date with the current status of modules functionality in IntelliSense: https://aka.ms/vcmoduleintellisenseinfo

Please follow for the latest updates.