星期三, 11月 30, 2005

The Definic Guide to GCC - 筆記 I

p.70
Build Source的步驟分為: 1.Preprocess 2.Compile 3.Assemble 4.Link
這四步驟GCC都可以自動工作。他是依照目標的副檔名來決定要作那一個動作:
1. .c, .C, .cc, .cpp, .cxx  : preprocess
2. .i, .ii : compile
3. .m : object C source code
4. .h : header
5. .s : assemble
6. .S : need preprocess assemble source
也 可以用 -x lang 指令指定類型。lang就是檔案類型,可以是:
c, object-c, c++, c-header, cpp-output,  c++-cpp-output,  assembler,  assembler-with-cpp.
另外,以下是用來控制compile process的選項:
 -c  : Link前終止。(compile only)
-E : preprocess後終止
-o file : 把輸出寫在 file 中
-S : 產生assembly後終止
-x lang : 其後所有檔案的語言都視為 lang
-x none: 取消上一個 -x lang的設定
GCC在處理後會用default的檔名和副檔名,例如 -c option作compile動作後產生objec檔,會以 .0 為副檔名。
用 -E 選項後會將結果輸出到standard out。所以要存檔的話,要用管線扶符號 " > " 重導到檔案。
用 -S 選項後會產生preprocess

沒有留言:

網誌存檔