是否有任何主要的C ++实现实际将NULL定义为nullptr?

问题描述 投票:0回答:1

自C ++ 11起,标准允许宏NULL成为值为零的整数文字或类型为std::nullptr_t的prvalue。

[任何标准库供应商决定将NULL的定义从整数更改为nullptr都很可能导致依赖C ++ 11之前代码的客户端损坏。

是否有任何主要实现(例如,GCC,Clang,MSVC)实际上将NULL定义为nullptr或尽管有可能,但没有人这样做吗?

c++ c++11 null c++-standard-library nullptr
1个回答
0
投票

[libstdc++ relies on including stddef.h,它通过以下方式定义stddef.h

NULL

[// <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 /* NULL not defined and <stddef.h> or need NULL. */ #undef __need_NULL libc++

does pretty much the same thing
© www.soinside.com 2019 - 2024. All rights reserved.