cxx/test/std/depr/depr.c.headers/stddef_h.pass.cpp
Richard Smith 759cd0e86b Split <stddef.h> out of <cstddef>.
There are a bunch of macros (__need_size_t etc) that request just one piece of
<stddef.h>; if any one of these is defined, we just directly include the
underlying header.

Note that <stddef.h> provides a ::nullptr_t. We don't want that available to
includers of <cstddef>, so instead of following the usual pattern where <cfoo>
includes <foo.h> then pulls things from :: into std:: with using-declarations,
we implement <stddef.h> and <cstddef> separately; both include <__nullptr> for
the definition of std::nullptr_t.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249761 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 22:25:27 +00:00

60 lines
2.2 KiB
C++

//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stddef.h>
#include <stddef.h>
#include <cassert>
#include <type_traits>
#ifndef NULL
#error NULL not defined
#endif
#ifndef offsetof
#error offsetof not defined
#endif
int main()
{
void *p = NULL;
assert(!p);
static_assert(sizeof(size_t) == sizeof(void*),
"sizeof(size_t) == sizeof(void*)");
static_assert(std::is_unsigned<size_t>::value,
"std::is_unsigned<size_t>::value");
static_assert(std::is_integral<size_t>::value,
"std::is_integral<size_t>::value");
static_assert(sizeof(ptrdiff_t) == sizeof(void*),
"sizeof(ptrdiff_t) == sizeof(void*)");
static_assert(std::is_signed<ptrdiff_t>::value,
"std::is_signed<ptrdiff_t>::value");
static_assert(std::is_integral<ptrdiff_t>::value,
"std::is_integral<ptrdiff_t>::value");
static_assert(std::is_same<decltype(nullptr), nullptr_t>::value,
"decltype(nullptr) == nullptr_t");
static_assert(sizeof(nullptr_t) == sizeof(void*),
"sizeof(nullptr_t) == sizeof(void*)");
static_assert(std::is_pod<max_align_t>::value,
"std::is_pod<max_align_t>::value");
static_assert((std::alignment_of<max_align_t>::value >=
std::alignment_of<long long>::value),
"std::alignment_of<max_align_t>::value >= "
"std::alignment_of<long long>::value");
static_assert(std::alignment_of<max_align_t>::value >=
std::alignment_of<long double>::value,
"std::alignment_of<max_align_t>::value >= "
"std::alignment_of<long double>::value");
static_assert(std::alignment_of<max_align_t>::value >=
std::alignment_of<void*>::value,
"std::alignment_of<max_align_t>::value >= "
"std::alignment_of<void*>::value");
}