Skip to content

Commit

Permalink
Merge pull request #339 from bradh352/master
Browse files Browse the repository at this point in the history
Windows: Inform compiler (GCC/MinGW) that format strings to use are GNU/c99 style
  • Loading branch information
brarcher committed Oct 22, 2021
2 parents a040522 + 3d2cf06 commit 455005d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/check.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,20 @@ CK_CPPSTART
#if GCC_VERSION_AT_LEAST(2,95,3)
#define CK_ATTRIBUTE_UNUSED __attribute__ ((unused))
#define CK_ATTRIBUTE_FORMAT(a, b, c) __attribute__ ((format (a, b, c)))

/* We use a private snprintf implementation that does not support the Windows
* format strings of %I64u or similar and instead support the C99 and GNU format
* format strings like %llu and %zu. Let the compiler know this. */
#ifdef _WIN32
#define CK_ATTRIBUTE_FORMAT_PRINTF gnu_printf
#else
#define CK_ATTRIBUTE_FORMAT_PRINTF printf
#endif

#else
#define CK_ATTRIBUTE_UNUSED
#define CK_ATTRIBUTE_FORMAT(a, b, c)
#define CK_ATTRIBUTE_FORMAT_PRINTF printf
#endif /* GCC 2.95 */

#if GCC_VERSION_AT_LEAST(2,5,0)
Expand Down Expand Up @@ -504,11 +515,11 @@ static void __testname ## _fn (int _i CK_ATTRIBUTE_UNUSED)
#if @HAVE_FORK@
CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line,
const char *expr, const char *msg,
...) CK_ATTRIBUTE_NORETURN CK_ATTRIBUTE_FORMAT(printf, 4, 5);
...) CK_ATTRIBUTE_NORETURN CK_ATTRIBUTE_FORMAT(CK_ATTRIBUTE_FORMAT_PRINTF, 4, 5);
#else
CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line,
const char *expr, const char *msg,
...) CK_ATTRIBUTE_FORMAT(printf, 4, 5);
...) CK_ATTRIBUTE_FORMAT(CK_ATTRIBUTE_FORMAT_PRINTF, 4, 5);
#endif

/**
Expand Down

0 comments on commit 455005d

Please sign in to comment.