Fixed memory leaks in test suite
[libgit2.git] / src / cc-compat.h
blobcf6cccf1297284833a9a03138a1f5738fa1c6c94
1 /*
2 * cc-compat.h - C compiler compat macros for internal use
3 */
4 #ifndef INCLUDE_compat_h__
5 #define INCLUDE_compat_h__
7 /*
8 * See if our compiler is known to support flexible array members.
9 */
10 #ifndef GIT_FLEX_ARRAY
11 # if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
12 # define GIT_FLEX_ARRAY /* empty */
13 # elif defined(__GNUC__)
14 # if (__GNUC__ >= 3)
15 # define GIT_FLEX_ARRAY /* empty */
16 # else
17 # define GIT_FLEX_ARRAY 0 /* older GNU extension */
18 # endif
19 # endif
21 /* Default to safer but a bit wasteful traditional style */
22 # ifndef GIT_FLEX_ARRAY
23 # define GIT_FLEX_ARRAY 1
24 # endif
25 #endif
27 #ifdef __GNUC__
28 # define GIT_TYPEOF(x) (__typeof__(x))
29 #else
30 # define GIT_TYPEOF(x)
31 #endif
33 #ifdef __cplusplus
34 # define GIT_UNUSED(x)
35 #else
36 # ifdef __GNUC__
37 # define GIT_UNUSED(x) x __attribute__ ((__unused__))
38 # else
39 # define GIT_UNUSED(x) x
40 # endif
41 #endif
43 #if defined(_MSC_VER)
44 #define GIT_UNUSED_ARG(x) ((void)(x)); /* note trailing ; */
45 #else
46 #define GIT_UNUSED_ARG(x)
47 #endif
50 * Does our compiler/platform support the C99 <inttypes.h> and
51 * <stdint.h> header files. (C99 requires that <inttypes.h>
52 * includes <stdint.h>).
54 #if !defined(_MSC_VER)
55 # define GIT_HAVE_INTTYPES_H 1
56 #endif
58 /* Define the printf format specifer to use for size_t output */
59 #if defined(_MSC_VER) || defined(__MINGW32__)
60 # define PRIuZ "Iu"
61 #else
62 # define PRIuZ "zu"
63 #endif
65 /* Micosoft Visual C/C++ */
66 #if defined(_MSC_VER)
67 /* disable "deprecated function" warnings */
68 # pragma warning ( disable : 4996 )
69 /* disable "conditional expression is constant" level 4 warnings */
70 # pragma warning ( disable : 4127 )
71 #endif
73 #endif /* INCLUDE_compat_h__ */