我想铿锵有力地捕捉到我无意中的“切换”语句失败。这个 shell 脚本演示了我的失败;我在脚本本身之后显示输出。我究竟做错了什么?
#!/bin/sh
cat <<EOD > 1.c
#include <stdio.h>
int main(void)
{
int etwas=5;
switch(etwas)
{
case 5:
{
printf("It's 5.\n");
}
case 6:
{
printf("It's 6.\n");
}
default:
{
printf("It's something else\n");
break;
}
}
return 0;
}
EOD
rm -f 1
clang --version
echo === demonstrating that unrecognized warning names are not allowed ===
clang -Wnonsense-warning -Werror -Wall 1.c -o 1
echo === The real compile follows. ===
clang -Wimplicit-fallthrough 1.c -o 1
echo === The execution follows. ===
./1
输出:
FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM 4.0.0)
Target: x86_64-unknown-freebsd11.1
Thread model: posix
InstalledDir: /usr/bin
=== demonstrating that unrecognized warning names are not allowed ===
error: unknown warning option '-Wnonsense-warning'
[-Werror,-Wunknown-warning-option]
=== The real compile follows. ===
=== The execution follows. ===
It's 5.
It's 6.
It's something else