1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <stddef.h>
10
11#include <stddef.h>
12
13#include "test_macros.h"
14
15void use() {
16 // Make sure we can use the following types without including anything else
17 (void)sizeof(size_t);
18 (void)sizeof(ptrdiff_t);
19#if TEST_STD_VER >= 11
20 (void)sizeof(nullptr);
21 (void)sizeof(nullptr_t);
22 (void)sizeof(max_align_t);
23#endif
24}
25
26#ifndef NULL
27#error NULL not defined
28#endif
29
30#ifndef offsetof
31#error offsetof not defined
32#endif
33
34#include <type_traits>
35
36static_assert(sizeof(size_t) == sizeof(void*), "");
37static_assert(std::is_unsigned<size_t>::value, "");
38static_assert(std::is_integral<size_t>::value, "");
39static_assert(sizeof(ptrdiff_t) == sizeof(void*), "");
40static_assert(std::is_signed<ptrdiff_t>::value, "");
41static_assert(std::is_integral<ptrdiff_t>::value, "");
42static_assert((std::is_same<decltype(nullptr), nullptr_t>::value), "");
43static_assert(sizeof(nullptr_t) == sizeof(void*), "");
44#if TEST_STD_VER >= 11
45# if TEST_STD_VER >= 20
46// P0767
47static_assert(std::is_trivial<max_align_t>::value, "");
48static_assert(std::is_standard_layout<max_align_t>::value, "");
49# else
50static_assert(std::is_pod<max_align_t>::value, "");
51# endif
52static_assert(std::alignment_of<max_align_t>::value >= std::alignment_of<long long>::value, "");
53static_assert(std::alignment_of<max_align_t>::value >= std::alignment_of<long double>::value, "");
54static_assert(std::alignment_of<max_align_t>::value >= std::alignment_of<void*>::value, "");
55#endif // TEST_STD_VER >= 11
56

source code of libcxx/test/std/depr/depr.c.headers/stddef_h.compile.pass.cpp