Skip to main content

Win32 API

Notes on building a Win32 C++ executable from VS Code with the MSVC toolchain. For the MSYS2/GCC toolchain instead, see C++.

Create a project in VS Code

  1. Press Ctrl+Shift+P and run CMake: Quick Start.
  2. Choose the kit Visual Studio Community 2022 Release - amd64.
  3. Select C++, then Executable.
  4. Press Ctrl+Shift+P and run CMake: Configure.
  5. Start debugging with C/C++: cl.exe build and debug active file.

Preprocessor

# Run the preprocessor without compiling.
# This can make the debugger behave erratically, so use it only for inspection.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /P")