]> git.proxmox.com Git - libgit2.git/blob - src/cc-compat.h
Merge branch 'development'
[libgit2.git] / src / cc-compat.h
1 /*
2 * Copyright (C) 2009-2012 the libgit2 contributors
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7 #ifndef INCLUDE_compat_h__
8 #define INCLUDE_compat_h__
9
10 /*
11 * See if our compiler is known to support flexible array members.
12 */
13 #ifndef GIT_FLEX_ARRAY
14 # if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
15 # define GIT_FLEX_ARRAY /* empty */
16 # elif defined(__GNUC__)
17 # if (__GNUC__ >= 3)
18 # define GIT_FLEX_ARRAY /* empty */
19 # else
20 # define GIT_FLEX_ARRAY 0 /* older GNU extension */
21 # endif
22 # endif
23
24 /* Default to safer but a bit wasteful traditional style */
25 # ifndef GIT_FLEX_ARRAY
26 # define GIT_FLEX_ARRAY 1
27 # endif
28 #endif
29
30 #ifdef __GNUC__
31 # define GIT_TYPEOF(x) (__typeof__(x))
32 #else
33 # define GIT_TYPEOF(x)
34 #endif
35
36 #define GIT_UNUSED(x) ((void)(x))
37
38 /* Define the printf format specifer to use for size_t output */
39 #if defined(_MSC_VER) || defined(__MINGW32__)
40 # define PRIuZ "Iu"
41 #else
42 # define PRIuZ "zu"
43 #endif
44
45 /* Micosoft Visual C/C++ */
46 #if defined(_MSC_VER)
47 /* disable "deprecated function" warnings */
48 # pragma warning ( disable : 4996 )
49 /* disable "conditional expression is constant" level 4 warnings */
50 # pragma warning ( disable : 4127 )
51 #endif
52
53 #if defined (_MSC_VER)
54 typedef unsigned char bool;
55 # define true 1
56 # define false 0
57 #else
58 # include <stdbool.h>
59 #endif
60
61 #ifndef va_copy
62 # ifdef __va_copy
63 # define va_copy(dst, src) __va_copy(dst, src)
64 # else
65 # define va_copy(dst, src) ((dst) = (src))
66 # endif
67 #endif
68
69 #endif /* INCLUDE_compat_h__ */