/*===---- stddef.h - Basic type definitions --------------------------------=== * * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. * See https://llvm.org/LICENSE.txt for license information. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception * *===-----------------------------------------------------------------------=== */ /* * This header is designed to be included multiple times. If any of the __need_ * macros are defined, then only that subset of interfaces are provided. This * can be useful for POSIX headers that need to not expose all of stddef.h, but * need to use some of its interfaces. Otherwise this header provides all of * the expected interfaces. * * When clang modules are enabled, this header is a textual header. It ignores * its header guard so that multiple submodules can export its interfaces. * Take module SM with submodules A and B, whose headers both include stddef.h * When SM.A builds, __STDDEF_H will be defined. When SM.B builds, the * definition from SM.A will leak when building without local submodule * visibility. stddef.h wouldn't include any of its implementation headers, and * SM.B wouldn't import any of the stddef modules, and SM.B's `export *` * wouldn't export any stddef interfaces as expected. However, since stddef.h * ignores its header guard when building with modules, it all works as * expected. * * When clang modules are not enabled, the header guards can function in the * normal simple fashion. */ #if !defined(__STDDEF_H) || __has_feature(modules) || \ (defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1) || \ defined(__need_ptrdiff_t) || defined(__need_size_t) || \ defined(__need_rsize_t) || defined(__need_wchar_t) || \ defined(__need_NULL) || defined(__need_nullptr_t) || \ defined(__need_unreachable) || defined(__need_max_align_t) || \ defined(__need_offsetof) || defined(__need_wint_t) #if !defined(__need_ptrdiff_t) && !defined(__need_size_t) && \ !defined(__need_rsize_t) && !defined(__need_wchar_t) && \ !defined(__need_NULL) && !defined(__need_nullptr_t) && \ !defined(__need_unreachable) && !defined(__need_max_align_t) && \ !defined(__need_offsetof) && !defined(__need_wint_t) #define __STDDEF_H #define __need_ptrdiff_t #define __need_size_t /* ISO9899:2011 7.20 (C11 Annex K): Define rsize_t if __STDC_WANT_LIB_EXT1__ is * enabled. */ #if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 #define __need_rsize_t #endif #define __need_wchar_t #define __need_NULL #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ defined(__cplusplus) #define __need_nullptr_t #endif #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L #define __need_unreachable #endif #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ (defined(__cplusplus) && __cplusplus >= 201103L) #define __need_max_align_t #endif #define __need_offsetof /* wint_t is provided by and not . It's here * for compatibility, but must be explicitly requested. Therefore * __need_wint_t is intentionally not defined here. */ #endif #if defined(__need_ptrdiff_t) #include <__stddef_ptrdiff_t.h> #undef __need_ptrdiff_t #endif /* defined(__need_ptrdiff_t) */ #if defined(__need_size_t) #include <__stddef_size_t.h> #undef __need_size_t #endif /*defined(__need_size_t) */ #if defined(__need_rsize_t) #include <__stddef_rsize_t.h> #undef __need_rsize_t #endif /* defined(__need_rsize_t) */ #if defined(__need_wchar_t) #include <__stddef_wchar_t.h> #undef __need_wchar_t #endif /* defined(__need_wchar_t) */ #if defined(__need_NULL) #include <__stddef_null.h> #undef __need_NULL #endif /* defined(__need_NULL) */ #if defined(__need_nullptr_t) #include <__stddef_nullptr_t.h> #undef __need_nullptr_t #endif /* defined(__need_nullptr_t) */ #if defined(__need_unreachable) #include <__stddef_unreachable.h> #undef __need_unreachable #endif /* defined(__need_unreachable) */ #if defined(__need_max_align_t) #include <__stddef_max_align_t.h> #undef __need_max_align_t #endif /* defined(__need_max_align_t) */ #if defined(__need_offsetof) #include <__stddef_offsetof.h> #undef __need_offsetof #endif /* defined(__need_offsetof) */ /* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use __WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */ #if defined(__need_wint_t) #include <__stddef_wint_t.h> #undef __need_wint_t #endif /* __need_wint_t */ #endif