]>
git.proxmox.com Git - libgit2.git/blob - src/cc-compat.h
f701b2d9351912e6259e9ae8a4107915f597a896
2 * Copyright (C) the libgit2 contributors. All rights reserved.
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.
7 #ifndef INCLUDE_cc_compat_h__
8 #define INCLUDE_cc_compat_h__
13 * See if our compiler is known to support flexible array members.
15 #ifndef GIT_FLEX_ARRAY
16 # if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
17 # define GIT_FLEX_ARRAY /* empty */
18 # elif defined(__GNUC__)
20 # define GIT_FLEX_ARRAY /* empty */
22 # define GIT_FLEX_ARRAY 0 /* older GNU extension */
26 /* Default to safer but a bit wasteful traditional style */
27 # ifndef GIT_FLEX_ARRAY
28 # define GIT_FLEX_ARRAY 1
33 # define GIT_ALIGN(x,size) x __attribute__ ((aligned(size)))
34 #elif defined(_MSC_VER)
35 # define GIT_ALIGN(x,size) __declspec(align(size)) x
37 # define GIT_ALIGN(x,size) x
41 # define GIT_UNUSED(x) \
43 __typeof__(x) _unused __attribute__((unused)); \
47 # define GIT_UNUSED(x) ((void)(x))
50 /* Define the printf format specifier to use for size_t output */
51 #if defined(_MSC_VER) || defined(__MINGW32__)
53 /* Visual Studio 2012 and prior lack PRId64 entirely */
55 # define PRId64 "I64d"
58 /* The first block is needed to avoid warnings on MingW amd64 */
59 # if (SIZE_MAX == ULLONG_MAX)
78 /* Micosoft Visual C/C++ */
80 /* disable "deprecated function" warnings */
81 # pragma warning ( disable : 4996 )
82 /* disable "conditional expression is constant" level 4 warnings */
83 # pragma warning ( disable : 4127 )
86 #if defined (_MSC_VER)
87 typedef unsigned char bool;
100 # define va_copy(dst, src) __va_copy(dst, src)
102 # define va_copy(dst, src) ((dst) = (src))