/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.
To set this compiler option in the Visual Studio development environment
You normally shouldn't set this option in the Visual Studio development environment unless you use a different extension for your module interface files. By default, the build system applies this option to files that have a .ixx
* extension.
To apply the
/interface
option to a file explicitly in the IDE, select the file in Solution Explorer. Right-click to open the context menu and select Properties to open the Property Pages dialog.Set the Configuration dropdown to All Configurations. Set the Platform dropdown to All Platforms.
Open the Configuration Properties > C/C++ > Advanced property page.
Use the dropdown control to modify the Compile As property to Compile as C++ Module Code (/interface). Choose OK or Apply to save your changes.
See also
Overview of modules in C++
Using C++ Modules in MSVC from the Command Line