#include <stdio.h>
#define MY_CONDITIONAL_MACRO
int main(void) {
#ifdef MY_CONDITIONAL_MACRO
printf("This code will get compiled.\n");
#endif
#ifdef NON_EXISTING_MACRO
printf("This code will not get compiled.\n");
#endif
return 0;
}
33、编写一个使用内置宏名称的程序。该程序应输出语句的行号、文件名、文件创建日期、被调用函数的名称以及当前使用的 C 标准。
#include <stdio.h>
void myfunction() {
printf("The name of the function called is: %s\n", __func__);
}
int main(void) {
printf("This statement is on line: %d\n", __LINE__);
printf("The name of the source file is: %s\n", __FILE__);
printf("The file was created on: %s\n", __DATE__);
myfunction();
printf("The C standard used is: %ld\n", __STDC_VERSION__);
return 0;
}