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

posted @ 2021-12-24 16:47  浩天之家  阅读(43)  评论(0编辑  收藏  举报