|
| 1 | +--- |
| 2 | +title: "/module:exportHeader (Create header units)" |
| 3 | +description: "Use the /module:exportHeader compiler option to create module header units for the header-name or include files specified." |
| 4 | +ms.date: 09/13/2020 |
| 5 | +f1_keywords: ["/module:exportHeader"] |
| 6 | +helpviewer_keywords: ["/module:exportHeader", "Create header units"] |
| 7 | +--- |
| 8 | +# `/module:exportHeader` (Create header units) |
| 9 | + |
| 10 | +Tells the compiler to create the header units specified by the input arguments. The compiler generates output in IFC (*`.ifc`*) files. |
| 11 | + |
| 12 | +## Syntax |
| 13 | + |
| 14 | +> **`/module:exportHeader`** *`header-name`* \[...]\ |
| 15 | +> **`/module:exportHeader`** *`filename`* \[...] |
| 16 | +
|
| 17 | +### Arguments |
| 18 | + |
| 19 | +*`header-name`*\ |
| 20 | +The header file to export. The *`header-name`* argument must take the same form as an argument to an `#include` directive. |
| 21 | + |
| 22 | +*`filename`*\ |
| 23 | +The relative or absolute path to the header file to create a header unit from. |
| 24 | + |
| 25 | +## Remarks |
| 26 | + |
| 27 | +The **`/module:exportHeader`** compiler option requires you enable experimental modules support by use of the [`/experimental:module`](experimental-module.md) compiler option, along with the [/std:c++latest](std-specify-language-standard-version.md) option. This option is available starting in Visual Studio 2019 version 16.8. |
| 28 | + |
| 29 | +One **`/module:exportHeader`** compiler option can specify as many header-name arguments as your build requires. You don't need to specify them separately. |
| 30 | + |
| 31 | +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)](fo-object-file-name.md). |
| 32 | + |
| 33 | +The compiler resolves a *`header-name`* based on the include directory search order, including any you specify. For more information, see [`/I` (Additional include directories)](i-additional-include-directories.md). |
| 34 | + |
| 35 | +The argument *`header-name`* must be specified the same way it would appear in source. The argument is sensitive to quoting rules and to `<` and `>` operators on the command line. The properly escaped command to build a header unit such as `<vector>` using the VS2019 command prompt might look like: |
| 36 | + |
| 37 | +```cmd |
| 38 | +cl ... /experimental:module /module:exportHeader "<vector>" |
| 39 | +``` |
| 40 | + |
| 41 | +Building a local project header such as `"utils/util.h"` might look like: |
| 42 | + |
| 43 | +```cmd |
| 44 | +cl ... /experimental:module /module:exportHeader """util/util.h""" |
| 45 | +``` |
| 46 | + |
| 47 | +The quoting rules in other command-line processors may differ. |
| 48 | + |
| 49 | +When using the *`header-name`* form of **`/module:exportHeader`**, you may find it's helpful to use the complementary option **`/module:showResolvedHeader`**. The **`/module:showResolvedHeader`** option prints an absolute path to the file the *`header-name`* argument resolves to. |
| 50 | + |
| 51 | +**`/module:exportHeader`** can handle multiple inputs at once even under **`/MP`**. We recommended you use **`/module:output <directory>`** to create a separate IFC file for each compilation. |
| 52 | + |
| 53 | +### Examples |
| 54 | + |
| 55 | +Given headers `"C:\util\util.h"` and `"C:\app\app.h"`, you can export them as *`header-name`* arguments by using this command: |
| 56 | + |
| 57 | +```cmd |
| 58 | +cl /IC:\ /experimental:module /module:exportHeader """util/util.h""" """app/app.h""" /FoC:\obj |
| 59 | +``` |
| 60 | + |
| 61 | +You can export them as *`filename`* arguments by using this command: |
| 62 | + |
| 63 | +```cmd |
| 64 | +cl /IC:\ /experimental:module /module:exportHeader C:\util\util.h C:\app\app.h /FoC:\obj |
| 65 | +``` |
| 66 | + |
| 67 | +### To set this compiler option in the Visual Studio development environment |
| 68 | + |
| 69 | +1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md). |
| 70 | + |
| 71 | +1. Set the **Configuration** drop-down to **All Configurations**. |
| 72 | + |
| 73 | +1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page. |
| 74 | + |
| 75 | +1. Modify the **Additional Options** property to add the *`/module:exportHeader`* option and any arguments. Then, choose **OK** or **Apply** to save your changes. |
| 76 | + |
| 77 | +## See also |
| 78 | + |
| 79 | +[`/experimental:module` (Enable module support)](experimental-module.md)\ |
| 80 | +[`/headerUnit` (Use header unit IFC)](headerunit.md)\ |
| 81 | +[`/module:reference` (Use named module IFC)](module-reference.md)\ |
| 82 | +[`/translateInclude` (Translate include directives into import directives)](translateinclude.md) |
0 commit comments