Skip to content

Commit

Permalink
技巧:只做语法检查
Browse files Browse the repository at this point in the history
  • Loading branch information
xingmingjie committed Jun 27, 2014
1 parent e20eb13 commit a607791
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
# 常见错误
* [error: cast from ... to ... loses precision](cast-lose-precision.md)

# 其它
* [只做语法检查](syntax-only.md)

22 changes: 22 additions & 0 deletions src/syntax-only.md
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a607791

Please sign in to comment.