| title | /headerName (Build a header unit from the specified header) | ||
|---|---|---|---|
| description | Use the /headerName compiler option to establish a mapping between a header file and the header unit to build. | ||
| ms.date | 04/13/2021 | ||
| author | tylermsft | ||
| ms.author | twhitney | ||
| f1_keywords |
|
||
| helpviewer_keywords |
|
Build the specified header file into a header unit (.ifc file).
/headerName:quoteheader-filename
/headerName:angleheader-filename
header-filename
The name of a header file that the compiler should compile into a header unit (.ifc file).
The /headerName compiler option is available starting in Visual Studio 2019 version 16.10.
The /headerName compiler option, in all its forms, requires the /std:c++20 or later compiler option (such as /std:c++latest).
If you specify /headerName:{quote,angle}, you must also specify /exportHeader.
/headerName:quote looks up header-filename using the same rules as #include "header-name" and builds it as a header unit (.ifc file).
/headerName:angle looks up header-filename using the same rules as #include <header-name> and builds it as a header unit (.ifc file).
Given a project that references a header file it defines called m.h, the compiler option to compile it into a header unit looks similar to this:
cl /std:c++latest /exportHeader /headerName:quote m.h /Fom.h.objThe /headerName:{quote,angle} option acts like a flag and does not explicitly need an argument. The following examples are valid:
cl /std:c++latest /exportHeader /headerName:angle /MP /Fo.\ vector iostream algorithm
cl /std:c++latest /exportHeader /headerName:quote /MP /Fo.\ my-utilities.h a/b/my-core.hYou can specify multiple /headerName options on the same command line, and every argument after that option will be processed with the specified header-filename lookup rules. The following example processes all the headers as the previous two command line examples in the same way. It looks up the headers using the lookup rules applied as if they had been specified as: #include <vector>, #include "my-utilties.h", and #include "a/b/my-core.h":
cl /std:c++latest /exportHeader /headerName:angle /MP /Fo.\ vector iostream algorithm /headerName:quote my-utilities.h a/b/my-core.hNote
Users don't typically set this command line option. It's set by the build system.
-
Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.
-
Set the Configuration drop-down to All Configurations.
-
Select the Configuration Properties > C/C++ > Command Line property page.
-
Modify the Additional Options property to add the
/headerNameoptions and arguments. Then, choose OK or Apply to save your changes.
/exportHeader (Create header units)
/headerUnit (Create header units)
/reference (Use named module IFC)
/translateInclude (Translate include directives into import directives)