]> git.proxmox.com Git - libgit2.git/blame - src/cc-compat.h
Merge pull request #1267 from libgit2/no-newline
[libgit2.git] / src / cc-compat.h
CommitLineData
f501265f 1/*
359fc2d2 2 * Copyright (C) the libgit2 contributors. All rights reserved.
bb742ede
VM
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.
f501265f
AE
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 */
2bf93fa1 13#ifndef GIT_FLEX_ARRAY
c060854e
VM
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
87d9869f 22# endif
f501265f
AE
23
24/* Default to safer but a bit wasteful traditional style */
c060854e
VM
25# ifndef GIT_FLEX_ARRAY
26# define GIT_FLEX_ARRAY 1
27# endif
f501265f
AE
28#endif
29
30#ifdef __GNUC__
c060854e 31# define GIT_TYPEOF(x) (__typeof__(x))
f501265f 32#else
c060854e 33# define GIT_TYPEOF(x)
f501265f
AE
34#endif
35
854eccbb 36#define GIT_UNUSED(x) ((void)(x))
73dcf287 37
8a086f87 38/* Define the printf format specifer to use for size_t output */
a1c0728d 39#if defined(_MSC_VER) || defined(__MINGW32__)
c060854e 40# define PRIuZ "Iu"
a1c0728d 41#else
c060854e 42# define PRIuZ "zu"
8a086f87
RJ
43#endif
44
5cae6c25
RJ
45/* Micosoft Visual C/C++ */
46#if defined(_MSC_VER)
47/* disable "deprecated function" warnings */
c060854e 48# pragma warning ( disable : 4996 )
ca3939e6 49/* disable "conditional expression is constant" level 4 warnings */
c060854e 50# pragma warning ( disable : 4127 )
5cae6c25
RJ
51#endif
52
1a481123
VM
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
1adf8c6a
VM
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
f501265f 69#endif /* INCLUDE_compat_h__ */