Skip to content

Commit 7788767

Browse files
committed
fixup
1 parent 6265847 commit 7788767

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

c/common.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ moocore_malloc(size_t nmemb, size_t size, const char *file, int line)
2727
#include <stdarg.h>
2828
#include <stdlib.h>
2929
#include <assert.h>
30-
#ifndef __USE_MINGW_ANSI_STDIO
31-
#define __USE_MINGW_ANSI_STDIO 1 // Add support for %zu in MinGW-w64's printf
32-
#endif
3330
#include <stdio.h>
3431
#include "gcc_attribs.h"
3532
#define Rprintf(...) printf(__VA_ARGS__)

c/gcc_attribs.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,25 @@
44
/* printf format-specifier for size_t */
55
#if defined(_MSC_VER) && (_MSC_VER < 1800) // MSVC before 2013
66
#define PRIsize_t "Iu"
7-
#elif defined(__MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO) && !defined(_UCRT)
8-
// MinGW-w64 with default MSVCRT runtime (without ANSI stdio)
9-
#define PRIsize_t "Iu"
7+
#elif defined(_UCRT)
8+
#define PRIsize_t "zu" // Standard C99 format
9+
#elif defined(__MINGW32__) && defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO == 0
10+
#include <inttypes.h>
11+
#define PRIsize_t PRIuPTR
1012
#else
1113
#define PRIsize_t "zu" // Standard C99 format
1214
#endif
1315

16+
#if defined(_UCRT)
17+
#pragma GCC warning "Using UCRT (Universal C Runtime)"
18+
#elif defined(__MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO)
19+
#pragma GCC warning "Using MSVCRT (Default MinGW-w64 runtime)"
20+
#elif defined(__USE_MINGW_ANSI_STDIO)
21+
#pragma GCC warning "Using MinGW-w64's custom ANSI printf"
22+
#else
23+
#pragma GCC warning "Using standard C runtime\n"
24+
#endif
25+
1426
/* FIXME: does this handle C++? */
1527
#ifndef __pure_func
1628
# define __pure_func __attribute__((__pure__))

0 commit comments

Comments
 (0)