forked from hellogcc/100-gcc-tips
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e20eb13
commit a607791
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,6 @@ | |
# 常见错误 | ||
* [error: cast from ... to ... loses precision](cast-lose-precision.md) | ||
|
||
# 其它 | ||
* [只做语法检查](syntax-only.md) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|