summaryrefslogtreecommitdiff
path: root/src/compiler.h
blob: 6a5ce4a81dbc8be1852ee0d5d36dbe8a6dfc20c3 (plain)
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
/**
 * \file compiler.h
 * Part of common.h, defines macros for hints to the compiler.
 */

#ifndef COMPILER_H
#define COMPILER_H

#if HAVE___ATTRIBUTE__
# define MALLOC __attribute__((malloc))
# define NONULL __attribute__((nonnull))
# define NONULL_ARGS(...) __attribute__((nonnull (__VA_ARGS__)))
# define PRINTF(_n,_m) __attribute__((format (printf, (_n), (_m))))
# define UNUSED __attribute__((unused))
#else
# warning Less compile time checks as compiler is unsupported
/**
 * Mark a function as always returning a new unique pointer or NULL
 */
# define MALLOC
/**
 * Mark a function as not taking NULL to any of its pointer parameters
 */
# define NONULL
/**
 * Mark a function as not taking NULL to the given list of pointer parameters.
 * The list of parameters is 1 based.
 */
# define NONULL_ARGS(...)
/**
 * Mark a function as taking printf format style parameter.
 * @param _n the 1 based index of the format parameter
 * @param _m the 1 based index of the first variable list parameter
 */
# define PRINTF(_n,_m)
/**
 * Mark a function paramter as being unused
 */
# define UNUSED
#endif

#endif /* COMPILER_H */