Skip to content

Commit 455005d

Browse files
authored
Merge pull request libcheck#339 from bradh352/master
Windows: Inform compiler (GCC/MinGW) that format strings to use are GNU/c99 style
2 parents a040522 + 3d2cf06 commit 455005d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/check.h.in

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,20 @@ CK_CPPSTART
6565
#if GCC_VERSION_AT_LEAST(2,95,3)
6666
#define CK_ATTRIBUTE_UNUSED __attribute__ ((unused))
6767
#define CK_ATTRIBUTE_FORMAT(a, b, c) __attribute__ ((format (a, b, c)))
68+
69+
/* We use a private snprintf implementation that does not support the Windows
70+
* format strings of %I64u or similar and instead support the C99 and GNU format
71+
* format strings like %llu and %zu. Let the compiler know this. */
72+
#ifdef _WIN32
73+
#define CK_ATTRIBUTE_FORMAT_PRINTF gnu_printf
74+
#else
75+
#define CK_ATTRIBUTE_FORMAT_PRINTF printf
76+
#endif
77+
6878
#else
6979
#define CK_ATTRIBUTE_UNUSED
7080
#define CK_ATTRIBUTE_FORMAT(a, b, c)
81+
#define CK_ATTRIBUTE_FORMAT_PRINTF printf
7182
#endif /* GCC 2.95 */
7283

7384
#if GCC_VERSION_AT_LEAST(2,5,0)
@@ -504,11 +515,11 @@ static void __testname ## _fn (int _i CK_ATTRIBUTE_UNUSED)
504515
#if @HAVE_FORK@
505516
CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line,
506517
const char *expr, const char *msg,
507-
...) CK_ATTRIBUTE_NORETURN CK_ATTRIBUTE_FORMAT(printf, 4, 5);
518+
...) CK_ATTRIBUTE_NORETURN CK_ATTRIBUTE_FORMAT(CK_ATTRIBUTE_FORMAT_PRINTF, 4, 5);
508519
#else
509520
CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line,
510521
const char *expr, const char *msg,
511-
...) CK_ATTRIBUTE_FORMAT(printf, 4, 5);
522+
...) CK_ATTRIBUTE_FORMAT(CK_ATTRIBUTE_FORMAT_PRINTF, 4, 5);
512523
#endif
513524

514525
/**

0 commit comments

Comments
 (0)