Skip to content

Commit b56af56

Browse files
author
Colin Robertson
committed
Bring /Fi up to snuff
1 parent 20142c4 commit b56af56

1 file changed

Lines changed: 31 additions & 9 deletions

File tree

docs/build/reference/fi-preprocess-output-file-name.md

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,49 @@ Specifies the name of the output file to which the [`/P` (Preprocess to a File)]
1313

1414
> **`/Fi`**_`pathname`_
1515
16-
#### Parameters
16+
### Parameters
1717

1818
*`pathname`*\
19-
The name and path of the output file produced by the **`/P`** compiler option.
19+
The relative or absolute path and filename of the output file produced by the **`/P`** compiler option. Or, the directory path for the *`.i`* output files when more than one input file is specified. Don't put a space between the **`/Fi`** option and *`pathname`*.
2020

2121
## Remarks
2222

23-
Use the **`/Fi`** compiler option in combination with the **`/P`** compiler option.
23+
Use the **`/Fi`** compiler option in combination with the **`/P`** compiler option. If **`/P`** isn't specified, **`/Fi`** causes command line warning D9007.
2424

25-
If you specify only a path for the *`pathname`* parameter, the base name of the source file is used as the base name of the preprocessed output file. The *`pathname`* parameter doesn't require a particular file name extension. However, an extension of ".i" is used if you don't specify a file name extension.
25+
If you specify only a directory path (a path that ends in a backslash **`\`**) for the *`pathname`* parameter, the base name of the source file is used as the base name of the preprocessed output file. The *`pathname`* parameter doesn't require a particular file name extension. However, an extension of ".i" is used if you don't specify a file name extension.
2626

27-
## Example
27+
### Example
2828

29-
The following command line preprocesses *`PROGRAM.cpp`*, preserves comments, adds [`#line`](../../preprocessor/hash-line-directive-c-cpp.md) directives, and writes the result to the *`MYPROCESS.i`* file.
29+
The following command line preprocesses *`PROGRAM.cpp`*, preserves comments, adds [`#line`](../../preprocessor/hash-line-directive-c-cpp.md) directives, and writes the result to the *`MYPROCESS.i`* file:
3030

3131
```cmd
3232
CL /P /FiMYPROCESS.I PROGRAM.CPP
3333
```
3434

35+
This command line preprocesses *`main.cpp`* and *`helper.cpp`* into *`main.i`* and *`helper.i`* in a subdirectory named *`preprocessed`*:
36+
37+
```cmd
38+
CL /P /Fi".\\preprocessed\\" main.cpp helper.cpp
39+
```
40+
41+
### To set this compiler option in the Visual Studio development environment
42+
43+
1. Open the source file or the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
44+
45+
1. Select the **Configuration Properties** > **C/C++** > **Preprocessor** property page.
46+
47+
1. Set the **Preprocess to a File** property to **Yes**.
48+
49+
1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
50+
51+
1. Enter the **`/Fi`** compiler option and *`pathname`* in the **Additional Options** box. Only specify a directory path, not a filename, when setting this property for a project.
52+
53+
### To set this compiler option programmatically
54+
55+
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A>.
56+
3557
## See also
3658

37-
[MSVC Compiler Options](compiler-options.md)<br/>
38-
[/P (Preprocess to a File)](p-preprocess-to-a-file.md)<br/>
39-
[Specifying the Pathname](specifying-the-pathname.md)
59+
[MSVC compiler options](compiler-options.md)<br/>
60+
[`/P` (Preprocess to a file)](p-preprocess-to-a-file.md)<br/>
61+
[Specifying the pathname](specifying-the-pathname.md)

0 commit comments

Comments
 (0)