簡易實用、語法高亮、比 Vim 易上手。安裝:
sudo apt-add-repository ppa:ubuntu-on-rails/ppa sudo apt-get update sudo apt-get install gedit-gmate
創建文件:touch test.c && gedit test.c。若高亮識別錯,編輯 → 高亮模式 → C。
Linux 事實標準,多數發行版預裝。源碼:
#include <stdio.h>
#include <stdlib.h>
int main() {
printf("Hello,Linux.\n");
exit(0);
}
gcc test.c -o test
生成可執行文件 test(Linux 無固定後綴)。運行:./test。無權限用 sudo chmod 777 test。
gcc -E test.c -o test.i(展開頭文件)gcc -S test.i -o test.sgcc -c test.s -o test.ogcc test.o -o test多文件編譯:
gcc -c test1.c -o test1.o gcc -c test2.c -o test2.o gcc test1.o test2.o -o test
未指定-o產生a.out。
-pedantic:檢測不符合 ANSI/ISO C 標準的代碼-Wall:顯示所有警告-Werror:將警告視為錯誤,停止編譯三選項極實用,建議常用。