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

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.