eĿlipsis
a language independent preprocessor
 
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Loading...
Searching...
No Matches
ellipsis-error.h
Go to the documentation of this file.
1
8#ifndef ELLIPSIS_ERROR_H
9#define ELLIPSIS_ERROR_H
10
11#ifdef __is_identifier
12# if __is_identifier(constexpr)
13# warning "constexpr keyword is not supported, emulating as static const"
14# define constexpr static const
15# endif
16#endif
17
18#ifndef __STRINGIFY__
19# define __STRINGIFY__(...) #__VA_ARGS__
20#endif
21
22extern bool ellipsis‿error‿dump;
23extern bool ellipsis‿error‿verb;
25
26#if __has_c_attribute(__gnu__::__format__)
27# define GNU_ATTR_FORMAT_PRINTF(...) [[__gnu__::__format__(__printf__, __VA_ARGS__)]]
28#else
29# define GNU_ATTR_FORMAT_PRINTF(...)
30#endif
31#if __has_c_attribute(__gnu__::__returns_nonnull__)
32# define GNU_ATTR_RETURNS_NONNULL [[__gnu__::__returns_nonnull__]]
33#else
34# define GNU_ATTR_RETURNS_NONNULL
35#endif
36#if __has_c_attribute(__gnu__::__used__)
37# define GNU_ATTR_USED [[__gnu__::__used__]]
38#else
39# define GNU_ATTR_USED
40#endif
41#if __has_c_attribute(__gnu__::__malloc__)
42# define GNU_ATTR_MALLOC(...) [[__gnu__::__malloc__ __VA_OPT__((__VA_ARGS__))]]
43#else
44# define GNU_ATTR_MALLOC(...)
45#endif
46#if __has_c_attribute(__gnu__::__access__)
47# define GNU_ATTR_ACCESS(...) [[__gnu__::__access__(__VA_ARGS__)]]
48#else
49# define GNU_ATTR_ACCESS(...)
50#endif
51#if __has_c_attribute(__gnu__::__strict_flex_array__)
52# define GNU_ATTR_STRICT_FLEX_ARRAY(...) [[__gnu__::__strict_flex_array__(__VA_ARGS__)]]
53#else
54# define GNU_ATTR_STRICT_FLEX_ARRAY(...)
55#endif
56#if __has_c_attribute(__gnu__::__counted_by__)
57# define GNU_ATTR_COUNTED_BY(...) [[__gnu__::__counted_by__(__VA_ARGS__)]]
58#else
59# define GNU_ATTR_COUNTED_BY(...)
60#endif
61#if __has_c_attribute(__nodiscard__) >= 202003L
62# define STDC_ATTR_NODISCARD(...) [[__nodiscard__ __VA_OPT__((__VA_ARGS__))]]
63#elif __has_c_attribute(__nodiscard__)
64# define STDC_ATTR_NODISCARD(...) [[__nodiscard__]]
65#elif __has_c_attribute(__gnu__::__warn_unused_result__)
66# define STDC_ATTR_NODISCARD(...) [[__gnu__::__warn_unused_result__]]
67#else
68# define STDC_ATTR_NODISCARD(...)
69#endif
70
75[[noreturn]]
76void ellipsis‿error(char const __LOC_ID_0_1[], ...);
77
81#define ELLIPSIS_ERROR(FORMAT, ...) ellipsis‿error("error, " FORMAT "\n" __VA_OPT__(,) __VA_ARGS__)
82
87#define ELLIPSIS_BUG(FORMAT, ...) ellipsis‿error("error, " FORMAT "\n" __VA_OPT__(,) __VA_ARGS__)
88
93void ellipsis‿error‿warning(char const __LOC_ID_0_2[], ...);
94
98#define ELLIPSIS_WARNING(FORMAT, ...) ellipsis‿error‿warning("warning, " FORMAT "\n" __VA_OPT__(,) __VA_ARGS__)
99
104void ellipsis‿error‿diagnostic(char const __LOC_ID_0_3[], ...);
105
109#define ELLIPSIS_DIAGNOSTIC(FORMAT, ...) ellipsis‿error‿diagnostic("diagnostic, " FORMAT "\n" __VA_OPT__(,) __VA_ARGS__)
110
122void ellipsis‿error‿deadend(char const __LOC_ID_0_4[], ...);
123
124#define ELLIPSIS_ERROR_CHECK(F, MESSAGE, ...) \
125({\
126 auto __LOC_ID_1_1 = F(__VA_ARGS__); \
127 if (!__LOC_ID_1_1) {\
128 ELLIPSIS_ERROR(__FILE__ ":" __STRINGIFY__(__LINE__) ": " MESSAGE); \
129 } \
130 __LOC_ID_1_1; \
131 })
132
133#ifndef _Lengthof
134
143#define _Lengthof(A) \
144_Generic(&(typeof(&((A)[0]))){}, \
145 typeof(A)*: (struct {\
146 static_assert(_Generic(&(typeof(&((A)[0]))){}, typeof(A)*: false, default: true), \
147 "_Lengthof needs an array parameter"); \
148 size_t _z; \
149 }){}._z, \
150 default: sizeof(A)/sizeof((A)[0]))
151#endif
152
153#endif
void ellipsis‿error‿diagnostic(char const format[],...)
Definition ellipsis-error.c:40
void ellipsis‿error(char const format[],...)
Definition ellipsis-error.c:64
void ellipsis‿error‿deadend(char const format[],...)
Definition ellipsis-error.c:75
void ellipsis‿error‿warning(char const format[],...)
Definition ellipsis-error.c:49
bool ellipsis‿error‿dump
Definition ellipsis-error.c:20
bool ellipsis‿error‿verb
Definition ellipsis-error.c:21
_Atomic bool ellipsis‿error‿finished
Definition ellipsis-error.c:22
#define GNU_ATTR_FORMAT_PRINTF(...)
Definition ellipsis-error.h:29
_Atomic(size_t)
Definition ellipsis-include.c:83