Skip to content

Commit bfdfbc9

Browse files
bandotimglambda
authored andcommitted
cleanup: fix compile warnings associated with gnu_printf (ggml-org#11811)
1 parent 4b0d032 commit bfdfbc9

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

common/common.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,13 +424,13 @@ bool set_process_priority(enum ggml_sched_priority prio);
424424
//
425425

426426
#ifdef __GNUC__
427-
#ifdef __MINGW32__
428-
#define LLAMA_COMMON_ATTRIBUTE_FORMAT(...) __attribute__((format(gnu_printf, __VA_ARGS__)))
427+
# if defined(__MINGW32__) && !defined(__clang__)
428+
# define LLAMA_COMMON_ATTRIBUTE_FORMAT(...) __attribute__((format(gnu_printf, __VA_ARGS__)))
429+
# else
430+
# define LLAMA_COMMON_ATTRIBUTE_FORMAT(...) __attribute__((format(printf, __VA_ARGS__)))
431+
# endif
429432
#else
430-
#define LLAMA_COMMON_ATTRIBUTE_FORMAT(...) __attribute__((format(printf, __VA_ARGS__)))
431-
#endif
432-
#else
433-
#define LLAMA_COMMON_ATTRIBUTE_FORMAT(...)
433+
# define LLAMA_COMMON_ATTRIBUTE_FORMAT(...)
434434
#endif
435435

436436
LLAMA_COMMON_ATTRIBUTE_FORMAT(1, 2)

common/log.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#ifndef __GNUC__
1717
# define LOG_ATTRIBUTE_FORMAT(...)
18-
#elif defined(__MINGW32__)
18+
#elif defined(__MINGW32__) && !defined(__clang__)
1919
# define LOG_ATTRIBUTE_FORMAT(...) __attribute__((format(gnu_printf, __VA_ARGS__)))
2020
#else
2121
# define LOG_ATTRIBUTE_FORMAT(...) __attribute__((format(printf, __VA_ARGS__)))

ggml/include/ggml.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198

199199
#ifndef __GNUC__
200200
# define GGML_ATTRIBUTE_FORMAT(...)
201-
#elif defined(__MINGW32__)
201+
#elif defined(__MINGW32__) && !defined(__clang__)
202202
# define GGML_ATTRIBUTE_FORMAT(...) __attribute__((format(gnu_printf, __VA_ARGS__)))
203203
#else
204204
# define GGML_ATTRIBUTE_FORMAT(...) __attribute__((format(printf, __VA_ARGS__)))

src/llama-impl.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
#include <vector>
77

88
#ifdef __GNUC__
9-
#ifdef __MINGW32__
10-
#define LLAMA_ATTRIBUTE_FORMAT(...) __attribute__((format(gnu_printf, __VA_ARGS__)))
9+
# if defined(__MINGW32__) && !defined(__clang__)
10+
# define LLAMA_ATTRIBUTE_FORMAT(...) __attribute__((format(gnu_printf, __VA_ARGS__)))
11+
# else
12+
# define LLAMA_ATTRIBUTE_FORMAT(...) __attribute__((format(printf, __VA_ARGS__)))
13+
# endif
1114
#else
12-
#define LLAMA_ATTRIBUTE_FORMAT(...) __attribute__((format(printf, __VA_ARGS__)))
13-
#endif
14-
#else
15-
#define LLAMA_ATTRIBUTE_FORMAT(...)
15+
# define LLAMA_ATTRIBUTE_FORMAT(...)
1616
#endif
1717

1818
//

tests/test-gguf.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,8 @@ static std::pair<int, int> test_handcrafted_file(const unsigned int seed) {
697697

698698
#ifdef _WIN32
699699
if (!file) {
700-
printf("%s: failed to create tmpfile(), needs elevated privileges on Windows");
701-
printf("%s: skipping tests");
700+
printf("failed to create tmpfile(), needs elevated privileges on Windows");
701+
printf("skipping tests");
702702
continue;
703703
}
704704
#else
@@ -1086,8 +1086,8 @@ static std::pair<int, int> test_roundtrip(ggml_backend_dev_t dev, const unsigned
10861086

10871087
#ifdef _WIN32
10881088
if (!file) {
1089-
printf("%s: failed to create tmpfile(), needs elevated privileges on Windows");
1090-
printf("%s: skipping tests");
1089+
printf("failed to create tmpfile(), needs elevated privileges on Windows");
1090+
printf("skipping tests");
10911091
return std::make_pair(0, 0);
10921092
}
10931093
#else

0 commit comments

Comments
 (0)