Skip to content

Commit

Permalink
技巧:指定语言类型
Browse files Browse the repository at this point in the history
  • Loading branch information
xingmingjie committed Jul 3, 2014
1 parent 85f5a20 commit 135a78f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@
* [只做语法检查](syntax-only.md)
* [保存临时文件](save-temps.md)
* [打开警告信息](turn-on-warnings.md)
* [指定语言类型](specify-language.md)

21 changes: 21 additions & 0 deletions src/specify-language.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 指定语言类型

## 技巧

gcc是通过文件名后缀来判断源代码语言类型的。

如果你从标准输入把源码传给gcc,那么就需要通过`-x`选项显式的指定语言类型:

$ echo "int x;" | gcc -S -x c -
$ cat ./-.s
.file ""
.comm x,4,4
.ident "GCC: (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3"
.section .note.GNU-stack,"",@progbits

详情参见[gcc手册](https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#Overall-Options)

## 贡献者

xmj

0 comments on commit 135a78f

Please sign in to comment.