Skip to content

Commit

Permalink
MinGW: Use correct format specifier (#54804)
Browse files Browse the repository at this point in the history
This cleans up all printf-related warnings when building Julia on Windows.
  • Loading branch information
topolarity committed Jun 17, 2024
1 parent 319d890 commit b0b7a85
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
17 changes: 11 additions & 6 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -2424,19 +2424,24 @@ typedef struct {
} jl_uv_file_t;

#ifdef __GNUC__
#define _JL_FORMAT_ATTR(type, str, arg) \
__attribute__((format(type, str, arg)))
# ifdef __MINGW32__
#define _JL_FORMAT_ATTR(str, arg) \
__attribute__((format(__MINGW_PRINTF_FORMAT, str, arg)))
# else
#define _JL_FORMAT_ATTR(str, arg) \
__attribute__((format(printf, str, arg)))
# endif
#else
#define _JL_FORMAT_ATTR(type, str, arg)
#define _JL_FORMAT_ATTR(str, arg)
#endif

JL_DLLEXPORT void jl_uv_puts(struct uv_stream_s *stream, const char *str, size_t n);
JL_DLLEXPORT int jl_printf(struct uv_stream_s *s, const char *format, ...)
_JL_FORMAT_ATTR(printf, 2, 3);
_JL_FORMAT_ATTR(2, 3);
JL_DLLEXPORT int jl_vprintf(struct uv_stream_s *s, const char *format, va_list args)
_JL_FORMAT_ATTR(printf, 2, 0);
_JL_FORMAT_ATTR(2, 0);
JL_DLLEXPORT void jl_safe_printf(const char *str, ...) JL_NOTSAFEPOINT
_JL_FORMAT_ATTR(printf, 1, 2);
_JL_FORMAT_ATTR(1, 2);

extern JL_DLLEXPORT JL_STREAM *JL_STDIN;
extern JL_DLLEXPORT JL_STREAM *JL_STDOUT;
Expand Down
2 changes: 1 addition & 1 deletion src/signals-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ LONG WINAPI jl_exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo)
default:
jl_safe_printf("UNKNOWN"); break;
}
jl_safe_printf(" at 0x%Ix -- ", (size_t)ExceptionInfo->ExceptionRecord->ExceptionAddress);
jl_safe_printf(" at 0x%zx -- ", (size_t)ExceptionInfo->ExceptionRecord->ExceptionAddress);
jl_print_native_codeloc((uintptr_t)ExceptionInfo->ExceptionRecord->ExceptionAddress);

jl_critical_error(0, 0, ExceptionInfo->ContextRecord, ct);
Expand Down
1 change: 0 additions & 1 deletion src/support/utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

#ifdef _OS_WINDOWS_
#include <malloc.h>
#define snprintf _snprintf
#else
#if !defined(__FreeBSD__) && !defined(__OpenBSD__)
#include <alloca.h>
Expand Down

0 comments on commit b0b7a85

Please sign in to comment.