辅导:C预处理和宏,第1张

辅导:C预处理和宏,第2张

预处理、宏、常量、变量
1。预处理
预处理常量
1.1__FILE__显示源文件
代码的完整路径和名称如
printf("文件% s \ n中的OCDE ",_
1.2__LINE__显示源文件
代码的当前行号如
printf("第% d \ n行中的代码",_ _ LINE _ _);
1.3__DATE__,__TIME__显示编译
printf("上次编译的% s% s \ n ",__DATE__,_ _ time _ _)等
代码时的日期和时间;
1.4__STDC__确定是否是标准ANSI C
# ifdef _ _ stdc _ _
printf("这是一个ANSI编译器\ n ");
#else
printf("这不是ANSI编译器\ n ");
# endif
1.5 _ _ cplusplus确定是否为C++源代码

# ifdef _ _ cplusplus
printf(" using c++ \ n ");
# else
printf(" using C \ n ");
# endif
1.6 # include与#include "filename.h "的区别"/br/] #include编译器将在当前系统的所有系统路径中查找此头文件
#include "filename.h "编译器将只在当前文件夹中查找此头文件
//完整代码演示
//per _ process . c
# include
per _ process(){
printf("文件% s中的ocde in
printf("第%d\n行中的ocde ",_ _ LINE _ _);
printf("上次编译的%s %s\n ",__DATE__,_ _ TIME _ _);
# ifdef _ MSC _ VER
printf("使用micrsoft编译器");
# endif
# ifdef _ borland c
printf("使用borland编译器");
# endif
# ifdef _ _ STDC _ _
printf("这是一个ANSI编译器\ n ");
#else
printf("这不是ANSI编译器\ n ");
# endif
# ifdef _ _ cplusplus
printf("使用c++ \ n ");
# else
printf(" using C \ n ");
# endif
}
main(){
per _ process();
}

位律师回复
DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
白度搜_经验知识百科全书 » 辅导:C预处理和宏

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情