-
Notifications
You must be signed in to change notification settings - Fork 255
Cpp2 setup: Visual Studio
Herb Sutter edited this page Oct 16, 2023
·
16 revisions
At the end of my CppCon 2023 talk, I showed debugging Cpp2 in Visual Studio. Several people asked how I set it up. Here's what I did.
Overview:
- Add the
.cpp2
file to the project. - Tell VS to build that file using a custom build tool to invoke cppfront. (I assume you already have cppfront installed.)
- That's it, once it builds the IDE and debugger should just pick up the error messages and debug step through the
.cpp2
file.
In the Solution Explorer, I just right-clicked on Source Files and picked Add to add the file to the project.
In Solution Explorer I could right-click on the .cpp2 file and select Properties:
And add the custom build tool:
Note that I had to also tell it that the custom build tool produced the .cpp file.
Also, be sure to put the /cppfront/include directory on your INCLUDE path, in Solution Explorer right-click the app and select Properties:
And add it to the VC++ Directories > Include Directories:
That's all I did, and all that was just to invoke cppfront to build.
The IDE just picks up the rest from:
- the cppfront error messages in
filename(line, col)
format which VS recognizes and merges any diagnostic output in the normal Errors window (if your IDE prefersfilename:line:col
just use the cppfront-format-colon-errors
command line option) - the
#line
directives cppfront emits in the generated.cpp
file so the debugger knows to step through the.cpp2
file (#line
emission is on by default, but if you choose-clean-cpp1
these will be suppressed and then the debugger will step through the generated C++ code instead)