From 9267745457c947da38e041de81a60425e52c53a5 Mon Sep 17 00:00:00 2001
From: Colin Robertson <3836425+corob-msft@users.noreply.github.com>
Date: Mon, 12 Dec 2022 15:41:03 -0800
Subject: [PATCH] Learn/corob/cpp docs 4335 (#4717)
* Address cpp-docs 4335 /Fo path
* More fixes.
---
docs/build/reference/fo-object-file-name.md | 32 ++++++++++++---------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/docs/build/reference/fo-object-file-name.md b/docs/build/reference/fo-object-file-name.md
index ea784342979..01fbb927b2a 100644
--- a/docs/build/reference/fo-object-file-name.md
+++ b/docs/build/reference/fo-object-file-name.md
@@ -1,35 +1,41 @@
---
title: "/Fo (Object file name)"
description: "Reference guide to the Microsoft C++ /Fo (Object file name) compiler option in Visual Studio."
-ms.date: "04/20/2020"
+ms.date: 12/12/2022
f1_keywords: ["/Fo", "VC.Project.VCCLCompilerTool.ObjectFile", "VC.Project.VCCLWCECompilerTool.ObjectFile"]
helpviewer_keywords: ["Fo compiler option [C++]", "object files, naming", "/Fo compiler option [C++]", "-Fo compiler option [C++]"]
ms.assetid: 0e6d593e-4e7f-4990-9e6e-92e1dcbcf6e6
---
-# /Fo (Object File Name)
+# `/Fo` (Object File Name)
Specifies an object (*`.obj`*) file name or directory to be used instead of the default.
## Syntax
-> **`/Fo`**_pathname_
+> **`/Fo`***`pathname`*
## Remarks
-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.
+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.
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.
-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.
+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.
-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.
+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.
## Example
-The following command line creates an object file named *sample.obj* in an existing directory, *\\intermediate*, on drive D.
+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:
```cmd
-CL /Fo"D:\intermediate\" /EHsc /c sample.cpp
+CL /Fo"D:\\intermediate\\" /EHsc /c sample1.cpp sample2.cpp
+```
+
+This command line creates object files named *`sample1.obj`* and *`sample2.obj`* in an existing directory, *`output\`*, relative to the source directory.
+
+```cmd
+CL /Fooutput\ /EHsc /c sample1.cpp sample2.cpp
```
## Set the option in Visual Studio or programmatically
@@ -40,7 +46,7 @@ CL /Fo"D:\intermediate\" /EHsc /c sample.cpp
1. Select the **Configuration Properties** > **C/C++** > **Output Files** property page.
-1. Modify the **Object File Name** property to set the output directory. In the IDE, the object file must have an extension of *`.obj`*.
+1. Modify the **Object File Name** property to set the output directory. In the IDE, the object files must have an extension of *`.obj`*.
### To set this compiler option programmatically
@@ -48,7 +54,7 @@ CL /Fo"D:\intermediate\" /EHsc /c sample.cpp
## See also
-[Output-File (/F) Options](output-file-f-options.md)
-[MSVC Compiler Options](compiler-options.md)
-[MSVC Compiler Command-Line Syntax](compiler-command-line-syntax.md)
-[Specifying the Pathname](specifying-the-pathname.md)
+[Output-file (`/F`) options](output-file-f-options.md)\
+[MSVC compiler options](compiler-options.md)\
+[MSVC compiler command-line syntax](compiler-command-line-syntax.md)\
+[Specifying the pathname](specifying-the-pathname.md)