之前一直使用vim+gcc+gdb在linux上搞,自己太菜,搞到不太順手,所以選來一款ide:CodeBlocks現在將使用中遇到的東東記下來。
1.設置參數
Settings->Debugger->GDB/CDB Debugger/Default->Debugger intialization conmmands: 輸入 set args 你的參數。
2.設置宏
Settings->Compiler->#defines 輸入要設置到宏
3.關閉-ansi選項
-ansi 只支持 ANSI 標準的 C 語法。這一選項將禁止 GNU C 的某些特色。關閉到緣由是由於從網上down下來來一篇代碼裏面用到來行註釋,總是報錯如下:
gcc -Wall -g -ansi -g -DGISKOOK -c /home/cetc/study/c13daemon_inted/daytimetcpsrv2.c -o obj/Debug/daytimetcpsrv2.o
/home/cetc/study/c13daemon_inted/daytimetcpsrv2.c:41: error: expected expression before ‘/’ token
/home/cetc/study/c13daemon_inted/daytimetcpsrv2.c:46: error: expected expression before ‘/’ token
/home/cetc/study/c13daemon_inted/daytimetcpsrv2.c:46: error: stray ‘\345’ in program
/home/cetc/study/c13daemon_inted/daytimetcpsrv2.c:46: error: stray ‘\210’ in program
自己用gcc編譯卻沒有問題,於是看到應該是要關閉-ansi選項。關閉步驟:Settings->Compiler->Compiler Flags->去掉相應選型.
4.我要編譯c++代碼可是總是使用的gcc,找了半天也沒有找到在哪設置比較好,所以只能在Setting->Compiler->Global compiler settings->Toolchain executables->program files下把c的編譯器改爲g++,着實不是一個好辦法。