Skip to content

Commit 09846f4

Browse files
authored
whisper: remove MSVC warnings pragmas (#3090)
* ggml : remove MSVC warnings pragmas This commit removes the MSVC-specific pragmas as these are now handled in CMakeLists.txt. * whisper : remove MSVC warning pragmas This commit removes the MSVC-specific pragmas. These are now handled in the CMakeLists.txt file.
1 parent bcf1ed0 commit 09846f4

16 files changed

+3
-78
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ if (MSVC)
232232
endfunction()
233233

234234
if (WHISPER_BUILD_EXAMPLES)
235+
disable_msvc_warnings(whisper)
235236
disable_msvc_warnings(common)
236237
disable_msvc_warnings(common-sdl)
237238
disable_msvc_warnings(lsp)

examples/cli/cli.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
#include <windows.h>
2121
#endif
2222

23-
#if defined(_MSC_VER)
24-
#pragma warning(disable: 4244 4267) // possible loss of data
25-
#endif
26-
2723
// helper function to replace substrings
2824
static void replace_all(std::string & s, const std::string & search, const std::string & replace) {
2925
for (size_t pos = 0; ; pos += replace.length()) {

examples/common-whisper.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@
2626
#define MINIAUDIO_IMPLEMENTATION
2727
#include "miniaudio.h"
2828

29-
#if defined(_MSC_VER)
30-
#pragma warning(disable: 4244 4267) // possible loss of data
31-
#endif
32-
3329
#ifdef _WIN32
3430
#include <fcntl.h>
3531
#include <io.h>

examples/common.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
#include <regex>
1111
#include <sstream>
1212

13-
#if defined(_MSC_VER)
14-
#pragma warning(disable: 4244 4267) // possible loss of data
15-
#endif
16-
1713
// Function to check if the next argument exists
1814
static std::string get_next_arg(int& i, int argc, char** argv, const std::string& flag, gpt_params& params) {
1915
if (i + 1 < argc && argv[i + 1][0] != '-') {

examples/server/server.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
#include <thread>
1515
#include <vector>
1616

17-
#if defined(_MSC_VER)
18-
#pragma warning(disable: 4244 4267) // possible loss of data
19-
#endif
20-
2117
using namespace httplib;
2218
using json = nlohmann::ordered_json;
2319

examples/talk-llama/llama.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
#include <cstring>
1717
#include <ctime>
1818

19-
#if defined(_MSC_VER)
20-
#pragma warning(disable: 4244 4267) // possible loss of data
21-
#endif
22-
2319
//
2420
// interface implementation
2521
//

ggml/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ if (MSVC)
366366
/wd4005 # Macro redefinition
367367
/wd4244 # Conversion from one type to another type, possible loss of data
368368
/wd4267 # Conversion from 'size_t' to a smaller type, possible loss of data
369+
/wd4996 # Disable POSIX deprecation warnings
370+
/wd4702 # Unreachable code warnings
369371
)
370372
function(disable_msvc_warnings target_name)
371373
if(TARGET ${target_name})

ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ static_assert(sizeof(block_iq4_nlx4) == 4 * sizeof(ggml_half) + QK4_NL * 2, "wro
7272

7373
#if defined(__GNUC__)
7474
#pragma GCC diagnostic ignored "-Woverlength-strings"
75-
#elif defined(_MSC_VER)
76-
#pragma warning(disable: 4244 4267) // possible loss of data
7775
#endif
7876

7977
#define UNUSED GGML_UNUSED

ggml/src/ggml-cpu/ggml-cpu-quants.c

-6
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@
2020
#define GROUP_MAX_EPS_IQ1_M 1e-7f
2121
#define GROUP_MAX_EPS_IQ1_S 1e-12f
2222

23-
#if defined(_MSC_VER)
24-
// disable "possible loss of data" to avoid warnings for hundreds of casts
25-
// we should just be careful :)
26-
#pragma warning(disable: 4244 4267)
27-
#endif
28-
2923
#define UNUSED GGML_UNUSED
3024

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

ggml/src/ggml-cpu/ggml-cpu.c

-13
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,6 @@
5050
#include "llamafile/sgemm.h"
5151
#endif
5252

53-
#if defined(_MSC_VER)
54-
// disable "possible loss of data" to avoid hundreds of casts
55-
// we should just be careful :)
56-
#pragma warning(disable: 4244 4267)
57-
58-
// disable POSIX deprecation warnings
59-
// these functions are never going away, anyway
60-
#pragma warning(disable: 4996)
61-
62-
// unreachable code because of multiple instances of code after GGML_ABORT
63-
#pragma warning(disable: 4702)
64-
#endif
65-
6653
// Note: once we move threading into a separate C++ file
6754
// will use std::hardware_destructive_interference_size instead of hardcoding it here
6855
// and we'll use C++ attribute syntax.

ggml/src/ggml-cpu/ops.cpp

-13
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,6 @@
88

99
#include <float.h>
1010

11-
#if defined(_MSC_VER)
12-
// disable "possible loss of data" to avoid hundreds of casts
13-
// we should just be careful :)
14-
#pragma warning(disable: 4244 4267)
15-
16-
// disable POSIX deprecation warnings
17-
// these functions are never going away, anyway
18-
#pragma warning(disable: 4996)
19-
20-
// unreachable code because of multiple instances of code after GGML_ABORT
21-
#pragma warning(disable: 4702)
22-
#endif
23-
2411
// ggml_compute_forward_dup
2512

2613
static void ggml_compute_forward_dup_same_cont(

ggml/src/ggml-cpu/vec.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
#include <cassert>
44

5-
#if defined(_MSC_VER)
6-
// disable "possible loss of data" to avoid hundreds of casts
7-
// we should just be careful :)
8-
#pragma warning(disable: 4244 4267)
9-
#endif
10-
115
// precomputed gelu table for f16 (128 KB)
126
ggml_fp16_t ggml_table_gelu_f16[1 << 16];
137

ggml/src/ggml-cuda/common.cuh

-4
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@ static int ggml_cuda_highest_compiled_arch(const int arch) {
130130

131131
#define MATRIX_ROW_PADDING 512 // last row of quant. matrices is a multiple of this to avoid out-of-bounds memory accesses
132132

133-
#if defined(_MSC_VER)
134-
#pragma warning(disable: 4244 4267) // possible loss of data
135-
#endif
136-
137133
#define GGML_CUDA_MAX_STREAMS 8
138134

139135
[[noreturn]]

ggml/src/ggml-quants.c

-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@
1919
#define GROUP_MAX_EPS_IQ1_M 1e-7f
2020
#define GROUP_MAX_EPS_IQ1_S 1e-12f
2121

22-
#if defined(_MSC_VER)
23-
// disable "possible loss of data" to avoid warnings for hundreds of casts
24-
// we should just be careful :)
25-
#pragma warning(disable: 4244 4267)
26-
#endif
27-
2822
#define UNUSED GGML_UNUSED
2923

3024
// reference implementation for deterministic creation of model files

ggml/src/ggml-sycl/common.hpp

-4
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ extern int g_ggml_sycl_disable_optimize;
8080
// max batch size to use MMQ kernels when tensor cores are available
8181
#define MMQ_MAX_BATCH_SIZE 32
8282

83-
#if defined(_MSC_VER)
84-
#pragma warning(disable : 4244 4267) // possible loss of data
85-
#endif
86-
8783
// dmmv = dequantize_mul_mat_vec
8884
#ifndef GGML_SYCL_DMMV_X
8985
#define GGML_SYCL_DMMV_X 32

src/whisper.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@
3737

3838
// dummy
3939

40-
#if defined(_MSC_VER)
41-
#pragma warning(disable: 4244 4267) // possible loss of data
42-
#endif
43-
4440
#if defined(WHISPER_BIG_ENDIAN)
4541
template<typename T>
4642
static T byteswap(T value) {

0 commit comments

Comments
 (0)