MSVC - 不显示编译器版本/版权信息

问题描述

我有一个生成文件

all: hello.cpp
    cl /EHsc hello.cpp

在开发者 powershell 中,当我输入 nmake 时,我得到:


Microsoft (R) Program Maintenance Utility Version 14.28.29915.0
copyright (C) Microsoft Corporation.  All rights reserved.

        cl /EHsc hello.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29915 for x86
copyright (C) Microsoft Corporation.  All rights reserved.

hello.cpp
Microsoft (R) Incremental Linker Version 14.28.29915.0
copyright (C) Microsoft Corporation.  All rights reserved.

/out:hello.exe
hello.obj

有没有办法不显示

Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29915 for x86
copyright (C) Microsoft Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 14.28.29915.0
copyright (C) Microsoft Corporation.  All rights reserved.

但只是显示

Microsoft (R) Program Maintenance Utility Version 14.28.29915.0
copyright (C) Microsoft Corporation.  All rights reserved.

        cl /EHsc hello.cpp

hello.cpp
/out:hello.exe
hello.obj

或类似的东西。我只是希望微软的横幅广告不显示,因为它们占用了不必要的行。

解决方法

正如 @dxiv 在评论中所建议的,添加 /nologo 标志似乎有效。修改后的makefile为:

all: hello.cpp
    cl /EHsc /nologo hello.cpp

开发人员 powershell 上的输出是:

Microsoft (R) Program Maintenance Utility Version 14.28.29915.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl /EHsc /nologo hello.cpp
hello.cpp

我不知道为什么微软觉得有必要默认显示这个(编译器版本和版权信息)信息,因为它完全没有必要。如果我需要编译器版本进行调试,我应该能够为 UNIX 执行类似于 cl -v 之类的操作。可以在 here 中找到更多标志。