#ifdef #undef 的应用

qianqiubiluo 2014-08-21 03:44:28
#ifdef interface
#undef interface
#endif
什么意思
...全文
220 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
707wk 2014-08-21
  • 打赏
  • 举报
回复
百度。。。。
日知己所无 2014-08-21
  • 打赏
  • 举报
回复
就是条件编译 #ifdef interface读作如果interface被定义了 #undef interface读作解除interface的定义 #endif读作条件编译完了 为什么要这么做,得看完整的代码才能理解
Saleayas 2014-08-21
  • 打赏
  • 举报
回复
#ifdef interface #undef interface // 一般会在这里重新定义 // 比如
#define interface IMyNewInterface
// 你可以看看 C 语言如何定义接口,就知道了。 #endif
mymtom 2014-08-21
  • 打赏
  • 举报
回复
这个真不好回答啊!
酒劍仙采葡萄 2014-08-21
  • 打赏
  • 举报
回复
#include <stdio.h>


int main()
{
#define interface 1
#ifdef interface
	printf("%d\n", interface);
#undef interface
	//printf("%d\n", interface);		// 这句话加上会报错 因为interface的定义被取消了
#endif
	getchar();
	return 0;
}
#undef 的作用就是取消先前的定义
风行踩火轮 2014-08-21
  • 打赏
  • 举报
回复
这是条件编译语句,告诉编译器你的编译规则而已,熟悉一下这几个语句的语法就好了
赵4老师 2014-08-21
  • 打赏
  • 举报
回复
#ifdef The #ifdef directive controls conditional compilation of the resource file by checking the specified name. If the name has been defined by using a #define directive or by using the /d command-line option with the resource compiler, #ifdef directs the compiler to continue with the statement immediately after the #ifdef directive. If the name has not been defined, #ifdef directs the compiler to skip all statements up to the next #endif directive. Syntax #ifdef name Parameters name Specifies the name to be checked by the directive. Example This example compiles the BITMAP statement only if the name Debug is defined: #ifdef Debug BITMAP 1 errbox.bmp #endif See Also #define, #endif, #if, #ifndef, #undef #undef The #undef directive removes the current definition of the specified name. All subsequent occurrences of the name are processed without replacement. Syntax #undef name Parameters name Specifies the name to be removed. This value is any combination of letters, digits, and punctuation. Example This example removes the definitions for the names nonzero and USERCLASS: #undef nonzero #undef USERCLASS See Also #define

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧