(5.4.1)--5.4TheUsageofgcc.ppt
《(5.4.1)--5.4TheUsageofgcc.ppt》由会员分享,可在线阅读,更多相关《(5.4.1)--5.4TheUsageofgcc.ppt(13页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、TheUsageofgccTheUsageofgccgcc v check the version number of gccgcc f1.c o f2(gcc f1.c)Example:#include int main()printf(hello worldn);return 0;The usage of gcchello.cCompile the program of multiple source files by gcc/mul1.c#include#include“my.h”main()printf(hello worldn);f();/mul2.c#include f()prin
2、tf(“in f()n”);/my.hvoid f();laidell lai gcc mul1.c mul2.c o m.outmul1.c/mul2.c/my.hCompile the program of multiple source files by gcc/mul1.c#include#include“my.h”main()printf(hello worldn);f();/mul2.c#include f()printf(“in f()n”);/my.hvoid f();laidell lai gcc mul1.c mul2.c o m.outThe defect of taki
3、ng gcc to compile the program of multiple source files:Every file must be recompiled.gcc contains complete functions of error checking and warning prompt to help programmers find error codes as soon as possible.gcc includes more than 30 warnings and three warning levels.Warning prompt of gccA bad ex
4、ampleThe main function doesnt use the return statement to return an int type value.Variable var is defined but not used.#include void main(void)long long int var=3;printf(this is not a standard c program!n);bad.cgcc-Wallbad.cWarning options of gccoptioinsoptioinsfunctionsfunctions-Wcomment-WcommentW
5、arnWarningingifcommentnestingoccurs(/*appearsafter/*)ifcommentnestingoccurs(/*appearsafter/*).-Wformat-WformatWarnWarningingiftheiftheparameterparameterpassedtopassedto printfdoesnprintfdoesn tmatchthespecifiedformattmatchthespecifiedformat.-Wmain-WmainWarnWarningingifthereturnifthereturntypetype of
6、mainisnotofmainisnotintintortheparametersareincorrectwhencallingmainortheparametersareincorrectwhencallingmain.-Wparentheses-WparenthesesBasedonthecontextinference,Basedonthecontextinference,warningwarningifif(n=10)n=10)iswritteniswrittenasas(n=10)(n=10).-Wswitch-WswitchWarnWarningingifoneormorecase
7、branchesaremissingfromtheswitch(onlyapplicabletoenum)ifoneormorecasebranchesaremissingfromtheswitch(onlyapplicabletoenum).-Wunused-WunusedWarningiftWarningifthevariableisdeclaredbutnotused,orthestatictypefunctionisnotcalledhevariableisdeclaredbutnotused,orthestatictypefunctionisnotcalled.-Wuninitial
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 5.4 TheUsageofgcc
限制150内