Skip to content

Commit 5eeed7b

Browse files
author
Colin Robertson
committed
Fix 2102 /Fo compiler option explanation
1 parent f393860 commit 5eeed7b

1 file changed

Lines changed: 24 additions & 19 deletions

File tree

docs/build/reference/fo-object-file-name.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,50 @@
11
---
2-
title: "/Fo (Object File Name)"
3-
ms.date: "11/04/2016"
2+
title: "/Fo (Object file name)"
3+
description: "Reference guide to the Microsoft C++ /Fo (Object file name) compiler option in Visual Studio."
4+
ms.date: "04/20/2020"
45
f1_keywords: ["/Fo", "VC.Project.VCCLCompilerTool.ObjectFile", "VC.Project.VCCLWCECompilerTool.ObjectFile"]
56
helpviewer_keywords: ["Fo compiler option [C++]", "object files, naming", "/Fo compiler option [C++]", "-Fo compiler option [C++]"]
67
ms.assetid: 0e6d593e-4e7f-4990-9e6e-92e1dcbcf6e6
78
---
89
# /Fo (Object File Name)
910

10-
Specifies an object (.obj) file name or directory to be used instead of the default.
11+
Specifies an object (*`.obj`*) file name or directory to be used instead of the default.
1112

1213
## Syntax
1314

14-
```
15-
/Fopathname
16-
```
15+
> **`/Fo`**_pathname_
1716
1817
## Remarks
1918

20-
If you do not use this option, the object file uses the base name of the source file and the .obj extension. You can use any name and extension you want, but the recommended convention is to use .obj.
19+
You can use the **`/Fo`** compiler option to set an output directory for all the object files generated by the CL compiler command. Or, you can use it to rename a single object file.
2120

22-
### To set this compiler option in the Visual Studio development environment
21+
By default, the object files generated by the compiler are placed in the current directory. They're given the base name of the source file and a *`.obj`* extension.
2322

24-
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).
23+
To use the **`/Fo`** option to rename an object file, specify the output filename as the *pathname* argument. When you rename an object file, you can use any name and extension you want, but the recommended convention is to use *`.obj`*. The compiler generates command line error D8036 if you specify a filename to **`/Fo`** when you've specified more than one source file to compile.
2524

26-
1. Click the **C/C++** folder.
25+
To use the **`/Fo`** option to set an output directory for all object files created by the CL command, specify the directory as the *pathname* argument. A directory is indicated by a trailing slash in the *pathname* argument. The specified directory must exist; it's not created automatically.
2726

28-
1. Click the **Output Files** property page.
27+
## Example
2928

30-
1. Modify the **Object File Name** property. In the development environment, the object file must have an extension of .obj.
29+
The following command line creates an object file named *sample.obj* in an existing directory, *\\intermediate*, on drive D.
3130

32-
### To set this compiler option programmatically
31+
```cmd
32+
CL /Fo"D:\intermediate\" /EHsc /c sample.cpp
33+
```
3334

34-
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.ObjectFile%2A>.
35+
## Set the option in Visual Studio or programmatically
3536

36-
## Example
37+
### To set this compiler option in the Visual Studio development environment
3738

38-
The following command line creates an object file named THIS.obj in an existing directory, \OBJECT, on drive B.
39+
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).
3940

40-
```
41-
CL /FoB:\OBJECT\ THIS.C
42-
```
41+
1. Select the **Configuration Properties** > **C/C++** > **Output Files** property page.
42+
43+
1. Modify the **Object File Name** property to set the output directory. In the IDE, the object file must have an extension of *`.obj`*.
44+
45+
### To set this compiler option programmatically
46+
47+
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.ObjectFile%2A>.
4348

4449
## See also
4550

0 commit comments

Comments
 (0)