简体   繁体   English

如何将 linker 警告视为 Clang 的错误?

[英]How do I treat linker warnings as errors with Clang?

I am using cmake.我正在使用 cmake。

I tried我试过了

-fatal-warnings (mentioned here ) -fatal-warnings此处提到)

-fatal_warnings (which is mentioned with man ld ) -fatal_warnings (与man ld一起提到)

Are those supposed to be used with -W ?那些应该与-W一起使用吗?

I would like all linker warnings across the whole project to be an error.我希望整个项目中的所有 linker 警告都是一个错误。

The warning I get is:我得到的警告是:

ld: warning: ignoring file libvst2sdk.a, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x23 0x31 0x2F 0x32 0x30 0x20 0x20 0x20 )

-Werror is a compiling flag that treat warnings as errors, and it's not linker flag. -Werror 是一个将警告视为错误的编译标志,它不是 linker 标志。

-Wl,--fatal-warnings -Wl,--致命警告
-Wl means pass options to linker. -Wl 表示将选项传递给 linker。

and here is pass 3 options to linker seperated by space:这是将 3 个选项传递给 linker,由空格分隔:
-Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--致命警告
or seperated by comma或以逗号分隔
-Wl,--build-id,--warn-shared-textrel,--fatal-warnings -Wl,--build-id,--warn-shared-textrel,--fatal-warnings

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM