]> git.proxmox.com Git - libgit2.git/blob - src/cc-compat.h
Tabify everything
[libgit2.git] / src / cc-compat.h
1 /*
2 * Copyright (C) 2009-2011 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 #ifdef __cplusplus
37 # define GIT_UNUSED(x)
38 #else
39 # ifdef __GNUC__
40 # define GIT_UNUSED(x) x __attribute__ ((__unused__))
41 # else
42 # define GIT_UNUSED(x) x
43 # endif
44 #endif
45
46 #if defined(_MSC_VER)
47 #define GIT_UNUSED_ARG(x) ((void)(x)); /* note trailing ; */
48 #else
49 #define GIT_UNUSED_ARG(x)
50 #endif
51
52 /*
53 * Does our compiler/platform support the C99 <inttypes.h> and
54 * <stdint.h> header files. (C99 requires that <inttypes.h>
55 * includes <stdint.h>).
56 */
57 #if !defined(_MSC_VER)
58 # define GIT_HAVE_INTTYPES_H 1
59 #endif
60
61 /* Define the printf format specifer to use for size_t output */
62 #if defined(_MSC_VER) || defined(__MINGW32__)
63 # define PRIuZ "Iu"
64 #else
65 # define PRIuZ "zu"
66 #endif
67
68 /* Micosoft Visual C/C++ */
69 #if defined(_MSC_VER)
70 /* disable "deprecated function" warnings */
71 # pragma warning ( disable : 4996 )
72 /* disable "conditional expression is constant" level 4 warnings */
73 # pragma warning ( disable : 4127 )
74 #endif
75
76 #endif /* INCLUDE_compat_h__ */