NULL可以跨平台使用吗

答案是可以。

windows平台上,在 Microsoft Visual Studio 10.0\VC\include\stdio.h 文件中有定义:


#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void*)0)
#endif

linux平台上,在 /usr/lib/gcc/x86-64-redhat-linux/4.8.2/include/stddef.h 文件中有定义:


#ifdef __GNUG__
	#define NULL __null
#else
	#ifndef __cplusplus
		#define NULL ((void*)0)
	#else
		#define NULL 0
	#endif
#endif

作者:浩天之家
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
Top
收藏
关注
评论
原文地址:https://www.cnblogs.com/cherishui/p/15728058.html