Been trying to add this flag: -Wshadow=compatible-local
(documentation) when compiling but it just keeps throwing this message:
试图添加这个标志:-Wshadow = compatible-local(文档)编译时它只是不断抛出这个消息:
`error: unknown warning option '-Wshadow=compatible-local';
did you mean '-Wshadow- uncaptured-local'?
[-Werror,-Wunknown-warning-option]`
Snippet of my makefile:
我的makefile的片段:
# COMPILER & FLAGS ============================================================
CC = gcc
CFLAGS = -g -std=c11 -O3 \
-Wall -Wextra -Werror \
-Wshadow -Wshadow=compatible-local \
-Wno-sign-compare \
-fsanitize=integer \
-fsanitize=undefined \
-fsanitize=address -fsanitize-address-use-after-scope
Updated:
更新:
Note: my compiler version is clang-900.0.39.2
. (It says clang
even though you type in gcc
, because I'm using macOS and well ... @Aconcagua explains why down below)
注意:我的编译器版本是clang-900.0.39.2。 (即使你输入gcc,它也会说clang,因为我正在使用macOS而且很好...... @Aconcagua解释了为什么在下面)
Someone know why this is happening ? and/or how to fix it ?
有人知道为什么会这样吗?和/或如何修复它?
2 个解决方案
#1
2
Some time ago, GCC was the default compiler on MacOS, then Apple decided to switch to clang as default. Suppose they linked GCC to clang to avoid people wondering why the compiler disappeared (well, more reasonable: not to break any build systems...). Good idea? At least leading to confusion where incompatibilities come into play...
前段时间,GCC是MacOS上的默认编译器,然后Apple决定切换到clang作为默认值。假设他们将GCC与clang联系起来,以避免人们想知道为什么编译器会消失(好吧,更合理:不要破坏任何构建系统......)。好主意?至少会导致混淆,因为不兼容性发挥作用......
"How to fix?"
“怎么修?”
Install a true GCC on your system, replacing the symlink to clang.
在您的系统上安装一个真正的GCC,将符号链接替换为clang。
If you prefer going on with clang (not a bad choice either), drop the flag that apparently is GCC-specific and not supported by clang (you can replace it with clang's equivalent, see vpetrigo's answer).
如果您喜欢继续使用clang(也不是一个糟糕的选择),请删除显然是GCC特定且不受clang支持的标志(您可以将其替换为clang的等效标题,请参阅vpetrigo的答案)。
You even might adapt your makefile to be compatible with both: Get the compiler's version string, check if the string returned contains "gcc" or "clang" and then add the appropriate compiler flags conditionally.
您甚至可以调整makefile以兼容两者:获取编译器的版本字符串,检查返回的字符串是否包含“gcc”或“clang”,然后有条件地添加适当的编译器标志。
#2
4
It seems that clang
uses quite different flag naming: http://clang.llvm.org/docs/DiagnosticsReference.html#wshadow-uncaptured-local
似乎clang使用了完全不同的标志命名:http://clang.llvm.org/docs/DiagnosticsReference.html#wshadow-uncaptured-local
It should be -Wshadow-uncaptured-local
rather than -Wshadow=compatible-local
.
它应该是-Wshadow-uncaptured-local而不是-Wshadow = compatible-local。
#1
2
Some time ago, GCC was the default compiler on MacOS, then Apple decided to switch to clang as default. Suppose they linked GCC to clang to avoid people wondering why the compiler disappeared (well, more reasonable: not to break any build systems...). Good idea? At least leading to confusion where incompatibilities come into play...
前段时间,GCC是MacOS上的默认编译器,然后Apple决定切换到clang作为默认值。假设他们将GCC与clang联系起来,以避免人们想知道为什么编译器会消失(好吧,更合理:不要破坏任何构建系统......)。好主意?至少会导致混淆,因为不兼容性发挥作用......
"How to fix?"
“怎么修?”
Install a true GCC on your system, replacing the symlink to clang.
在您的系统上安装一个真正的GCC,将符号链接替换为clang。
If you prefer going on with clang (not a bad choice either), drop the flag that apparently is GCC-specific and not supported by clang (you can replace it with clang's equivalent, see vpetrigo's answer).
如果您喜欢继续使用clang(也不是一个糟糕的选择),请删除显然是GCC特定且不受clang支持的标志(您可以将其替换为clang的等效标题,请参阅vpetrigo的答案)。
You even might adapt your makefile to be compatible with both: Get the compiler's version string, check if the string returned contains "gcc" or "clang" and then add the appropriate compiler flags conditionally.
您甚至可以调整makefile以兼容两者:获取编译器的版本字符串,检查返回的字符串是否包含“gcc”或“clang”,然后有条件地添加适当的编译器标志。
#2
4
It seems that clang
uses quite different flag naming: http://clang.llvm.org/docs/DiagnosticsReference.html#wshadow-uncaptured-local
似乎clang使用了完全不同的标志命名:http://clang.llvm.org/docs/DiagnosticsReference.html#wshadow-uncaptured-local
It should be -Wshadow-uncaptured-local
rather than -Wshadow=compatible-local
.
它应该是-Wshadow-uncaptured-local而不是-Wshadow = compatible-local。