/interface

This switch instructs the compiler to treat the input file on the command line as a module interface unit.

Syntax

/interface filename

Remarks

Use this switch when a module interface has a different extension than .ixx.

In the following example, the module interface has a .cppm extension instead of .ixx, so the /interface switch is used to compile it as a module interface:

cl /c /std:c++latest /interface /TP my-module.cppm

The compiler derives the name for the generated .ifc file from the module interface name. For example, given a module name MyModule defined in my-module.cppm, the generated .ifc will be named MyModule.ifc.

This switch must be used in with the /TP (Specify source file type) compiler flag.

/interface is available in Visual Studio 2019 version 16.10, or later.
/interface requires /std:c++20 or later.

See also

Overview of modules in C++
Using C++ Modules in MSVC from the Command Line