相关疑难解决方法(0)

64位系统上的NULL定义问题

我正在使用gcc 4.1.2在RHEL 5.1 64位平台上运行.

我有一个实用功能:

void str_concat(char *buff, int buffSize, ...);
Run Code Online (Sandbox Code Playgroud)

concats char*在可变参数列表(...)中传递,而最后一个参数应为NULL,以指定参数的结尾.在64位系统上,NULL是8个字节.

现在来问题了.我的应用程序直接/间接包含2个stddef.h文件.

第一个是/usr/include/linux/stddef.h,它定义NULL如下:

#undef NULL
#if defined(__cplusplus)
#define NULL 0
#else
#define NULL ((void *)0)
#endif
Run Code Online (Sandbox Code Playgroud)

第二个是/usr/lib/gcc/x86_64-redhat-linux/4.1.2/include/stddef.h

#if defined (_STDDEF_H) || defined (__need_NULL)
#undef NULL     /* in case <stdio.h> has defined it. */
#ifdef __GNUG__
#define NULL __null
#else   /* G++ */
#ifndef __cplusplus
#define NULL ((void *)0)
#else   /* C++ */
#define NULL 0
#endif  /* C++ */
#endif  /* G++ */
#endif  /* …
Run Code Online (Sandbox Code Playgroud)

c++ linux 64-bit null gcc

2
推荐指数
2
解决办法
5028
查看次数

标签 统计

64-bit ×1

c++ ×1

gcc ×1

linux ×1

null ×1