From a607791466259463ed1ab7fccf608fe949de1a75 Mon Sep 17 00:00:00 2001 From: xmj Date: Fri, 27 Jun 2014 17:44:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=80=E5=B7=A7=EF=BC=9A=E5=8F=AA=E5=81=9A?= =?UTF-8?q?=E8=AF=AD=E6=B3=95=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.md | 3 +++ src/syntax-only.md | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/syntax-only.md diff --git a/src/index.md b/src/index.md index bb51015..010cc97 100644 --- a/src/index.md +++ b/src/index.md @@ -7,3 +7,6 @@ # 常见错误 * [error: cast from ... to ... loses precision](cast-lose-precision.md) +# 其它 +* [只做语法检查](syntax-only.md) + diff --git a/src/syntax-only.md b/src/syntax-only.md new file mode 100644 index 0000000..2c512cd --- /dev/null +++ b/src/syntax-only.md @@ -0,0 +1,22 @@ +# 只做语法检查 + +## 例子 + + $ cat foo.c + uion { + char c; + int i; + } + $ gcc -fsyntax-only foo.c + foo.c:1:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token + +## 技巧 + +如上所示,使用`-fsyntax-only`选项可以只做语法检查,不进行实际的编译输出。 + +详情参见[gcc手册](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-fsyntax-only-274) + +## 贡献者 + +xmj +