-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.h
45 lines (38 loc) · 1.1 KB
/
util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
/**
* @file util.h
* @brief PPS (CS-212) Tool macros
*
* @author Jean-Cédric Chappelier
* @date 2017-2021
*/
#include <assert.h> // see TO_BE_IMPLEMENTED
/**
* @brief tag a variable as POTENTIALLY unused, to avoid compiler warnings
*/
#define _unused __attribute__((unused))
/**
* @brief useful for partial implementation
*/
#define TO_BE_IMPLEMENTED() \
do { \
fprintf(stderr, "TO_BE_IMPLEMENTED!\n"); \
assert(0); \
} while (0)
/**
* @brief useful to free pointers to const without warning. Use with care!
*/
#define free_const_ptr(X) free((void *)X)
/**
* @brief useful to have C99 (!) %zu to compile in Windows
*/
#if defined _WIN32 || defined _WIN64
#define SIZE_T_FMT "%u"
#else
#define SIZE_T_FMT "%zu"
#endif
/**
* @brief useful to specify a length defined by a macro for format strings
*/
#define STR(x) #x
#define STR_LENGTH_FMT(x) "%." STR(x) "s"