| title | /exportHeader (Create header units) | ||
|---|---|---|---|
| description | Use the /exportHeader compiler option to create module header units for the header-name or include files specified. | ||
| ms.date | 05/18/2020 | ||
| author | tylermsft | ||
| ms.author | twhitney | ||
| f1_keywords |
|
||
| helpviewer_keywords |
|
Tells the compiler to create the header units specified by the input arguments. The compiler generates header units as IFC (.ifc) files.
/exportHeader /headerName:angleheader-name
/exportHeader /headerName:quoteheader-name
/exportHeaderfull path to header file
The argument to /exportHeader is a /headerName command-line option that specifies the name, header-name, of the header file to export.
/exportHeader is available starting in Visual Studio 2019 version 16.10.
The /exportHeader compiler option requires you enable the /std:c++20 or later compiler option (such as /std:c++latest).
One /exportHeader compiler option can specify as many header-name arguments as your build requires. You don't need to specify them separately.
The compiler implicitly enables the new preprocessor when this option is used. That is, /Zc:preprocessor is added to the command line by the compiler if any form of /exportHeader is used on the command line. To opt out of the implicit /Zc:preprocessor, use: /Zc:preprocessor-
By default, the compiler doesn't produce an object file when a header unit is compiled. To produce an object file, specify the /Fo compiler option. For more information, see /Fo (Object File Name).
You may find it helpful to use the complementary option /showResolvedHeader. The /showResolvedHeader option prints an absolute path to the file the header-name argument resolves to.
/exportHeader can handle multiple inputs at once, even under /MP. We recommended you use /ifcOutput <directory> to create a separate .ifc file for each compilation.
To build a header unit such as <vector> might look like:
cl . . . /std:c++latest /exportHeader /headerName:angle vectorBuilding a local project header such as "utils/util.h" might look like:
cl . . . /std:c++latest /exportHeader /headerName:quote util/util.hYou normally shouldn't set this option in the Visual Studio development environment unless you use a different extension for your header files. By default, the build system applies this option to compiled files that have a .h extension, or no extension.
-
To apply the
/exportHeaderoption 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++ Header Unit (/exportHeader). Choose OK or Apply to save your changes.
/headerName (Build a header unit from the specified header)
/headerUnit (Use header unit IFC)
/reference (Use named module IFC)
/translateInclude (Translate include directives into import directives)