]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/include/base.h
d3363744b04b184be3e6f3c861b93b5ed3b1b1e0
[pes-rpp/rpp-lib.git] / rpp / include / base.h
1 /**
2  * Base common includes to all RPP library.
3  *
4  * @file base.h
5  *
6  * @copyright Copyright (C) 2013, 2015 Czech Technical University in Prague
7  *
8  * @author Carlos Jenkins <carlos@jenkins.co.cr>
9  */
10
11 #ifndef __BASE_H
12 #define __BASE_H
13
14 // Base includes
15 #include "types.h"
16 #include "binary.h"
17 #include "os/os.h"
18 #include <assert.h>
19
20 // General IO directives
21 /**
22  * Maximum length of system buffers.
23  */
24 #define MAX_BUFFER_LEN 1024
25
26
27 // Debug directives
28 /**
29  * Macro to mark unused variables.
30  */
31 #define UNUSED(x) (void)(x)
32
33 /**
34  * General debug directive.
35  */
36 //#define DEBUG // - defined in preprocessor's Predefined symbols
37
38 #ifdef DEBUG
39 /**
40  * Macro to mark debug statements.
41  */
42 #  define D(x) x
43 #else
44 #  define D(x)
45 #endif
46
47 /** Calculates the number of elements in an array */
48 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(*(x)))
49
50 #if defined(static_assert)
51 /** Static assertion as available in C11 standard */
52 #define STATIC_ASSERT(COND,MSG) static_assert(COND, #MSG)
53 #else
54 /** Static assertion - non-C11 fall-back */
55 #define STATIC_ASSERT(COND,MSG) typedef char static_assertion_##MSG[(COND)?1:-1]
56 #endif
57
58 #endif /* __BASE_H */