/headerName (Build a header unit from the specified header)

Build the specified header file into a header unit (.ifc file).

Syntax

/headerName:quote header-filename
/headerName:angle header-filename

Arguments

header-filename
The name of a header file that the compiler should compile into a header unit (.ifc file).

Remarks

The /headerName:quote and /headerName:angle compiler options are available starting in Visual Studio 2019 version 16.10.

The /headerName compiler options, in all their forms, require the /std:c++20 or later compiler option (such as /std:c++latest).
If you specify a /headerName option, you must also specify /exportHeader.

  • /headerName:quote looks up header-filename using the same rules as #include "header-filename" and builds it as a header unit (.ifc file).
  • /headerName:angle looks up header-filename using the same rules as #include <header-filename> and builds it as a header unit (.ifc file).

For more information about the path searching rules for included files in quotes or angle brackets, see #include directive.

Examples

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 example:

cl /std:c++latest /exportHeader /headerName:quote m.h /Fom.h.obj

The /headerName:quote and /headerName:angle options act like a flag and don't 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.h

You can specify multiple /headerName options on the same command line. Every argument after a /headerName option is processed with the specified include file lookup rules for quotes or angle brackets until the next /headerName option. The following example processes all the headers as the previous two command line examples in the same way as before. It looks up the headers using the lookup rules applied as if they had been specified as: #include <vector>, #include <iostream>, #include <algorithm>, #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.h

To set this compiler option in the Visual Studio development environment

Note

You normally shouldn't set this option in the Visual Studio development environment. It's set by the build system.

  1. Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.

  2. Set the Configuration drop-down to All Configurations. Set the Platform drop-down to All Platforms.

  3. Select the Configuration Properties > C/C++ > Command Line property page.

  4. Modify the Additional Options property to add the /headerName:quote or /headerName:angle options and the header filenames the options apply to. Then, choose OK or Apply to save your changes.

See also

/exportHeader (Create header units)
/headerUnit (Use header unit IFC)
/reference (Use named module IFC)
/translateInclude (Translate include directives into import directives)