Skip to content

Commit 8e48473

Browse files
committed
Merging changes synced from https://github.com/MicrosoftDocs/cpp-docs-pr (branch live)
2 parents 2114e52 + 9cdeb14 commit 8e48473

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed
Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,41 @@
11
---
22
title: "/Fo (Object file name)"
33
description: "Reference guide to the Microsoft C++ /Fo (Object file name) compiler option in Visual Studio."
4-
ms.date: "04/20/2020"
4+
ms.date: 12/12/2022
55
f1_keywords: ["/Fo", "VC.Project.VCCLCompilerTool.ObjectFile", "VC.Project.VCCLWCECompilerTool.ObjectFile"]
66
helpviewer_keywords: ["Fo compiler option [C++]", "object files, naming", "/Fo compiler option [C++]", "-Fo compiler option [C++]"]
77
ms.assetid: 0e6d593e-4e7f-4990-9e6e-92e1dcbcf6e6
88
---
9-
# /Fo (Object File Name)
9+
# `/Fo` (Object File Name)
1010

1111
Specifies an object (*`.obj`*) file name or directory to be used instead of the default.
1212

1313
## Syntax
1414

15-
> **`/Fo`**_pathname_
15+
> **`/Fo`***`pathname`*
1616
1717
## Remarks
1818

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.
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. Don't put a space between the **`/Fo`** option and the *`pathname`* argument.
2020

2121
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.
2222

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.
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 an *`.obj`* extension. 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.
2424

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.
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 or backslash in the *`pathname`* argument. Use an escaped backslash (a double backslash), if you're using a quoted path. The directory path can be absolute, or relative to the source directory. The specified directory must exist, or the compiler reports error D8003. The directory isn't created automatically.
2626

2727
## Example
2828

29-
The following command line creates an object file named *sample.obj* in an existing directory, *\\intermediate*, on drive D.
29+
The following command line creates object files named *`sample1.obj`* and *`sample2.obj`* in an existing directory, *`D:\intermediate\`*. It uses escaped backslash characters as path segment separators in a quoted path:
3030

3131
```cmd
32-
CL /Fo"D:\intermediate\" /EHsc /c sample.cpp
32+
CL /Fo"D:\\intermediate\\" /EHsc /c sample1.cpp sample2.cpp
33+
```
34+
35+
This command line creates object files named *`sample1.obj`* and *`sample2.obj`* in an existing directory, *`output\`*, relative to the source directory.
36+
37+
```cmd
38+
CL /Fooutput\ /EHsc /c sample1.cpp sample2.cpp
3339
```
3440

3541
## Set the option in Visual Studio or programmatically
@@ -40,15 +46,15 @@ CL /Fo"D:\intermediate\" /EHsc /c sample.cpp
4046

4147
1. Select the **Configuration Properties** > **C/C++** > **Output Files** property page.
4248

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`*.
49+
1. Modify the **Object File Name** property to set the output directory. In the IDE, the object files must have an extension of *`.obj`*.
4450

4551
### To set this compiler option programmatically
4652

4753
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.ObjectFile%2A>.
4854

4955
## See also
5056

51-
[Output-File (/F) Options](output-file-f-options.md)<br/>
52-
[MSVC Compiler Options](compiler-options.md)<br/>
53-
[MSVC Compiler Command-Line Syntax](compiler-command-line-syntax.md)<br/>
54-
[Specifying the Pathname](specifying-the-pathname.md)
57+
[Output-file (`/F`) options](output-file-f-options.md)\
58+
[MSVC compiler options](compiler-options.md)\
59+
[MSVC compiler command-line syntax](compiler-command-line-syntax.md)\
60+
[Specifying the pathname](specifying-the-pathname.md)

0 commit comments

Comments
 (0)