如何为 Microsoft cmdline 编译器 cl 自定义 .exe 文件名?

Ltf*_*4an 7 filenames compiler-errors rename visual-studio output

我从谷歌搜索中找到的唯一两个选项是 /OUT 和 /Fe,但都不适合我:

使用 /Fe 显示没有错误,但在当前目录中也找不到输出文件:

C:\hands_on\C>cl /Fe:test.exe main.c
Microsoft (R) C/C++ Optimizing Compiler Version 15.00.30729.01 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

main.c
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out::test.exe
main.obj

C:\hands_on\C>ls
main.c  main.obj
Run Code Online (Sandbox Code Playgroud)

使用 /OUT 会出现错误:

C:\hands_on\C>cl /OUT:test.exe main.c
Microsoft (R) C/C++ Optimizing Compiler Version 15.00.30729.01 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9025 : overriding '/Ot' with '/Os'
cl : Command line warning D9025 : overriding '/Os' with '/Ot'
cl : Command line warning D9002 : ignoring unknown option '/OU'
cl : Command line warning D9002 : ignoring unknown option '/OT'
cl : Command line warning D9002 : ignoring unknown option '/O:'
cl : Command line warning D9002 : ignoring unknown option '/Oe'
cl : Command line warning D9002 : ignoring unknown option '/O.'
cl : Command line warning D9002 : ignoring unknown option '/Oe'
cl : Command line warning D9002 : ignoring unknown option '/Oe'
main.c
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:main.exe
main.obj
Run Code Online (Sandbox Code Playgroud)

编译器版本:

C:\hands_on\C>cl
Microsoft (R) C/C++ Optimizing Compiler Version 15.00.30729.01 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]
Run Code Online (Sandbox Code Playgroud)

Chr*_*isF 10

语法是:

cl /Fetest.exe main.c
Run Code Online (Sandbox Code Playgroud)

没有空格或标点符号,或者:

cl /Fe: test.exe main.c
Run Code Online (Sandbox Code Playgroud)

带有冒号和空格。

你有一个冒号但没有空格:

cl /Fe:test.exe main.c
Run Code Online (Sandbox Code Playgroud)

来源