clang API Documentation

stddef.h
Go to the documentation of this file.
00001 /*===---- stddef.h - Basic type definitions --------------------------------===
00002  *
00003  * Copyright (c) 2008 Eli Friedman
00004  *
00005  * Permission is hereby granted, free of charge, to any person obtaining a copy
00006  * of this software and associated documentation files (the "Software"), to deal
00007  * in the Software without restriction, including without limitation the rights
00008  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00009  * copies of the Software, and to permit persons to whom the Software is
00010  * furnished to do so, subject to the following conditions:
00011  *
00012  * The above copyright notice and this permission notice shall be included in
00013  * all copies or substantial portions of the Software.
00014  *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00018  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00019  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00020  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00021  * THE SOFTWARE.
00022  *
00023  *===-----------------------------------------------------------------------===
00024  */
00025 
00026 #if !defined(__STDDEF_H) || defined(__need_ptrdiff_t) ||                       \
00027     defined(__need_size_t) || defined(__need_wchar_t) ||                       \
00028     defined(__need_NULL) || defined(__need_wint_t)
00029 
00030 #if !defined(__need_ptrdiff_t) && !defined(__need_size_t) &&                   \
00031     !defined(__need_wchar_t) && !defined(__need_NULL) &&                       \
00032     !defined(__need_wint_t)
00033 /* Always define miscellaneous pieces when modules are available. */
00034 #if !__has_feature(modules)
00035 #define __STDDEF_H
00036 #endif
00037 #define __need_ptrdiff_t
00038 #define __need_size_t
00039 #define __need_wchar_t
00040 #define __need_NULL
00041 #define __need_STDDEF_H_misc
00042 /* __need_wint_t is intentionally not defined here. */
00043 #endif
00044 
00045 #if defined(__need_ptrdiff_t)
00046 #if !defined(_PTRDIFF_T) || __has_feature(modules)
00047 /* Always define ptrdiff_t when modules are available. */
00048 #if !__has_feature(modules)
00049 #define _PTRDIFF_T
00050 #endif
00051 typedef __PTRDIFF_TYPE__ ptrdiff_t;
00052 #endif
00053 #undef __need_ptrdiff_t
00054 #endif /* defined(__need_ptrdiff_t) */
00055 
00056 #if defined(__need_size_t)
00057 #if !defined(_SIZE_T) || __has_feature(modules)
00058 /* Always define size_t when modules are available. */
00059 #if !__has_feature(modules)
00060 #define _SIZE_T
00061 #endif
00062 typedef __SIZE_TYPE__ size_t;
00063 #endif
00064 #undef __need_size_t
00065 #endif /*defined(__need_size_t) */
00066 
00067 #if defined(__need_STDDEF_H_misc)
00068 /* ISO9899:2011 7.20 (C11 Annex K): Define rsize_t if __STDC_WANT_LIB_EXT1__ is
00069  * enabled. */
00070 #if (defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 && \
00071      !defined(_RSIZE_T)) || __has_feature(modules)
00072 /* Always define rsize_t when modules are available. */
00073 #if !__has_feature(modules)
00074 #define _RSIZE_T
00075 #endif
00076 typedef __SIZE_TYPE__ rsize_t;
00077 #endif
00078 #endif /* defined(__need_STDDEF_H_misc) */
00079 
00080 #if defined(__need_wchar_t)
00081 #ifndef __cplusplus
00082 /* Always define wchar_t when modules are available. */
00083 #if !defined(_WCHAR_T) || __has_feature(modules)
00084 #if !__has_feature(modules)
00085 #define _WCHAR_T
00086 #if defined(_MSC_EXTENSIONS)
00087 #define _WCHAR_T_DEFINED
00088 #endif
00089 #endif
00090 typedef __WCHAR_TYPE__ wchar_t;
00091 #endif
00092 #endif
00093 #undef __need_wchar_t
00094 #endif /* defined(__need_wchar_t) */
00095 
00096 #if defined(__need_NULL)
00097 #undef NULL
00098 #ifdef __cplusplus
00099 #  if !defined(__MINGW32__) && !defined(_MSC_VER)
00100 #    define NULL __null
00101 #  else
00102 #    define NULL 0
00103 #  endif
00104 #else
00105 #  define NULL ((void*)0)
00106 #endif
00107 #ifdef __cplusplus
00108 #if defined(_MSC_EXTENSIONS) && defined(_NATIVE_NULLPTR_SUPPORTED)
00109 namespace std { typedef decltype(nullptr) nullptr_t; }
00110 using ::std::nullptr_t;
00111 #endif
00112 #endif
00113 #undef __need_NULL
00114 #endif /* defined(__need_NULL) */
00115 
00116 #if defined(__need_STDDEF_H_misc)
00117 #if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L
00118 #include "__stddef_max_align_t.h"
00119 #endif
00120 #define offsetof(t, d) __builtin_offsetof(t, d)
00121 #undef __need_STDDEF_H_misc
00122 #endif  /* defined(__need_STDDEF_H_misc) */
00123 
00124 /* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use
00125 __WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */
00126 #if defined(__need_wint_t)
00127 /* Always define wint_t when modules are available. */
00128 #if !defined(_WINT_T) || __has_feature(modules)
00129 #if !__has_feature(modules)
00130 #define _WINT_T
00131 #endif
00132 typedef __WINT_TYPE__ wint_t;
00133 #endif
00134 #undef __need_wint_t
00135 #endif /* __need_wint_t */
00136 
00137 #endif