libpulsar
A modular compiler for the pulsar programming language
Loading...
Searching...
No Matches
def.h
Go to the documentation of this file.
1
8#pragma once
9
10#ifndef __GNUC__
11"GNU C is required to compile this project. Please use a compatible compiler "
12 "such as gcc or clang."
13#endif
14
15/* Standard includes */
16#include <inttypes.h>
17#include <stdbool.h>
18#include <stddef.h>
19
20/* Posix includes */
21#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
22 #include <unistd.h>
23#endif
24#ifndef _POSIX_VERSION
25 "POSIX library functions are required to compile this project."
26#endif
27#include <sys/types.h>
28
29#ifndef _PS_PUBLIC_SRC
30 #define __join_eval(x, y) x##y
31 #define __join(x, y) __join_eval(x, y)
32
33 // Used to silence -Wempty-translation-unit
34 #define W_NO_EMPTY_TRANSLATION_UNIT() \
35 __join(struct dummy_struct, __COUNTER__)
37 #undef W_NO_EMPTY_TRANSLATION_UNIT
38#endif
39
40#define STR const char*
41#define i8 int8_t
42#define u8 uint8_t
43#define i16 int16_t
44#define u16 uint16_t
45#define i32 int32_t
46#define u32 uint32_t
47#define i64 int64_t
48#define u64 uint64_t
49#define isize ssize_t
50#define usize size_t
51#define f32 float
52#define f64 double
53#define auto_t __auto_type
54
55#define lengthof(array) (sizeof(array) / sizeof(*(array)))
56#define _A(attr) __attribute__((attr))
57#ifdef _PS_PUBLIC_SRC
58 #undef STR
59 #undef i8
60 #undef u8
61 #undef i16
62 #undef i32
63 #undef i64
64 #undef u64
65 #undef isize
66 #undef usize
67 #undef f32
68 #undef f64
69 #undef auto_t
70 #undef PS_PRINT_TEMPLATE
71 #undef BOOLSTR
72#else
73 #define _STRING_EVAL(x) #x
74 #define _STRING(x) _STRING_EVAL(x)
75 #define BOOLSTR(x) ((x) ? "true" : "false")
76#endif /* _PS_PUBLIC_SRC */
77
78#ifdef PS_DEBUG
79 #include "util/abort.h"
80 #define ps_exit(code) ps_abort_with_code("Exiting program.", code)
81#endif
Defines assertion and abortion functionality.
#define W_NO_EMPTY_TRANSLATION_UNIT()
Definition def.h:34