PLATFORM TOOLSET

C/C++ can be used to develop standalone modules or gauges for Microsoft Flight Simulator through a specific Platform Toolset named Microsoft Flight Simulator which installs at the same time as the SDK itself (see Additional Tools for more details). While previous iterations of the game compiled the C/C++ code into a DLL, the new toolset compiles it into a WebAssembly module (extension " *.wasm"). This module can then be either placed in the modules subfolder of a package to be automatically loaded when the said packaged is mounted, or referenced from an aircraft panel.cfg file if it includes gauges (in a similar manner to the old DLLs).

 

 

Requirements

In order to use the Microsoft Flight Simulator Platform Toolset, you need to have Visual Studio 2017 or later installed.

 

 

Creating A Project

The Microsoft Flight Simulator Platform Toolset comes with a few predefined Visual Studio templates for your projects which you can use as follows:

  • Start Visual Studio.
  • Select the " Create a New Project" option.
  • In the filters select "C++" for the language, "Microsoft Flight Simulator" for the platform and "WebAssembly" for the project type.
  • In the list below the filters, select "MSFS WASM Module", "MSFS WASM Static Library" or "MSFS WASM Gauge Demo" and press Next.
  • In the "Configure your new project" window, select the location of the project and press Create.

 

You can find a complete tutorial to get you started on the following page:

 

 

Migrating a project

If you already have a project developed for other platforms, you can easily add a new configuration to support Microsoft Flight Simulator:

  • Start Visual Studio.
  • Open your project/solution.
  • Once your project is loaded, right-click on the solution in the "Solution Explorer" and use the "Properties" option.
  • In the left list, click on "Configuration Properties".
  • Click on " Configuration Manager" in the top right corner of the window.
  • Click on the "Active solution platform" list and select "<New...>".
  • In the "Type or select the new platform:" list, select MSFS. In the "Copy settings from:" list, select "". Make sure the " Create new project platforms" checkbox is checked.
  • Press "OK".

 

 

Visual Studio Configuration

When setting up Visual Studio it should be noted that you have ways to further optimise building the WASM module, using the following option:

*/clang:-OX*

Where X is either 0, 1, 2 or 3:

  • */clang:-O0*: this is the default mode, where there will be lots of instructions meaning it will take more time to be executed. However it will also have debug data and you will be able to put breakpoint and step through the code. Use this option in development.
  • */clang:-O3*: this must be used for release builds. When using this, there are a lot of extra optimizations processed, with less instructions giving a faster module. However, this means that debug data is optimized and so you can't use breakpoints or code stepping.
  • */clang:-O1, 2.*: These are "middle" levels of optimization, and can be used if required, although it's not generally necessary.

 

 

Debugging

If you need to debug a compiled WASM module, then there is also an extension available for Visual Studio that can help you do this as well as a WASM Debug window for viewing specific details in the simulation. Please see here for more information: