Skip to content

Commit c8aade0

Browse files
committed
Added improved way to check for PRIu64 etc
1 parent 47f5bd9 commit c8aade0

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/jc_test.h

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,26 @@ struct jc_test_params_class : public jc_test_base_class {
202202
#endif
203203

204204
#if !defined(JC_FMT_U64)
205-
#if defined(__ANDROID__)
206-
#define JC_FMT_U64 "%llu"
207-
#define JC_FMT_I64 "%lld"
208-
#else
209-
#if __cplusplus == 199711L && (defined(__GNUC__) && !defined(__clang__))
210-
// For some reason GCC would always warn about the format not working in c++98 (it does though)
211-
#pragma GCC diagnostic ignored "-Wformat"
205+
#if defined(__has_include)
206+
#if __has_include(<inttypes.h>)
207+
#include <inttypes.h>
212208
#endif
213-
#include <inttypes.h>
214-
#define JC_FMT_U64 "%" PRIu64
215-
#define JC_FMT_I64 "%" PRId64
216209
#endif
210+
211+
#if !defined(PRId64)
212+
#if defined(_MSC_VER)
213+
#define PRId64 "I64d"
214+
#define PRIi64 "I64i"
215+
#define PRIu64 "I64u"
216+
#define PRIx64 "I64x"
217+
#else
218+
#define PRIu64 "llu"
219+
#define PRIx64 "lld"
220+
#endif
221+
#endif
222+
223+
#define JC_FMT_U64 "%" PRIu64
224+
#define JC_FMT_I64 "%" PRId64
217225
#endif
218226

219227
#if defined(__x86_64__) || defined(__arm64) || defined(__aarch64__) || defined(__ppc64__) || defined(_WIN64)
@@ -2054,6 +2062,7 @@ INSTANTIATE_TEST_CASE_P(EvenValues, MyParamTest, jc_test_values(2,4,6,8,10));
20542062
* Made sure to compile with highest warning/error levels possible
20552063
*
20562064
* HISTORY:
2065+
* 0.12 2025-09-24 * Added more robust way to check for PRIu64 etc
20572066
* 0.11 2023-10-13 * Added JC_TEST_OUTPUT_FN for customizing log output
20582067
* * Added JC_TEST_USE_PRINTF to choose printf() over write()
20592068
* 0.10 2023-05-19 * Introduced JC_TEXT_LOGGER_CLASS for easier log printing

0 commit comments

Comments
 (0)