Skip to content

Commit ef0d5e3

Browse files
iboBggerganov
authored andcommitted
build: fix and ignore msvc warnings (ggml/805)
1 parent 3292733 commit ef0d5e3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

ggml-backend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,9 +1182,9 @@ static int ggml_backend_sched_backend_id_from_cur(ggml_backend_sched_t sched, st
11821182
static char * fmt_size(size_t size) {
11831183
static char buffer[128];
11841184
if (size >= 1024*1024) {
1185-
sprintf(buffer, "%zuM", size/1024/1024);
1185+
snprintf(buffer, sizeof(buffer), "%zuM", size/1024/1024);
11861186
} else {
1187-
sprintf(buffer, "%zuK", size/1024);
1187+
snprintf(buffer, sizeof(buffer), "%zuK", size/1024);
11881188
}
11891189
return buffer;
11901190
}

ggml-quants.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
#include <stdlib.h> // for qsort
1515
#include <stdio.h> // for GGML_ASSERT
1616

17+
#if defined(_MSC_VER)
18+
// disable "possible loss of data" to avoid warnings for hundreds of casts
19+
// we should just be careful :)
20+
#pragma warning(disable: 4244 4267)
21+
#endif
22+
1723
#define UNUSED GGML_UNUSED
1824

1925
// some compilers don't provide _mm256_set_m128i, e.g. gcc 7

0 commit comments

Comments
 (0)