]> git.proxmox.com Git - libgit2.git/blob - src/cc-compat.h
win32: Add support for the MS Visual C/C++ compiler
[libgit2.git] / src / cc-compat.h
1 /*
2 * cc-compat.h - C compiler compat macros for internal use
3 */
4 #ifndef INCLUDE_compat_h__
5 #define INCLUDE_compat_h__
6
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
20
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
26
27 #ifdef __GNUC__
28 # define GIT_TYPEOF(x) (__typeof__(x))
29 #else
30 # define GIT_TYPEOF(x)
31 #endif
32
33 /*
34 * Does our compiler/platform support the C99 <inttypes.h> and
35 * <stdint.h> header files. (C99 requires that <inttypes.h>
36 * includes <stdint.h>).
37 */
38 #if !defined(_MSC_VER)
39 # define GIT_HAVE_INTTYPES_H 1
40 #endif
41
42 /* Define the printf format specifer to use for size_t output */
43 #if !defined(_MSC_VER)
44 # define PRIuZ "zu"
45 #else
46 # define PRIuZ "Iu"
47 #endif
48
49 /* Micosoft Visual C/C++ */
50 #if defined(_MSC_VER)
51 /* no direct support for C99 inline function specifier */
52 # define inline __inline
53 /* disable "deprecated function" warnings */
54 # pragma warning ( disable : 4996 )
55 #endif
56
57 #endif /* INCLUDE_compat_h__ */