Skip to content

Commit 4ef7c5f

Browse files
committed
Disable msvc warnings in source files
...instead of from the cmake build file.
1 parent 36f969d commit 4ef7c5f

File tree

11 files changed

+30
-17
lines changed

11 files changed

+30
-17
lines changed

CMakeLists.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,6 @@ if(MSVC)
6464
xcheck_add_c_compiler_flag(-Wno-reserved-identifier)
6565
xcheck_add_c_compiler_flag(-Wdeprecated-declarations)
6666
xcheck_add_c_compiler_flag(/experimental:c11atomics)
67-
xcheck_add_c_compiler_flag(/wd4018) # -Wno-sign-conversion
68-
xcheck_add_c_compiler_flag(/wd4061) # -Wno-implicit-fallthrough
69-
xcheck_add_c_compiler_flag(/wd4100) # -Wno-unused-parameter
70-
xcheck_add_c_compiler_flag(/wd4200) # -Wno-zero-length-array
71-
xcheck_add_c_compiler_flag(/wd4242) # -Wno-shorten-64-to-32
72-
xcheck_add_c_compiler_flag(/wd4244) # -Wno-shorten-64-to-32
73-
xcheck_add_c_compiler_flag(/wd4245) # -Wno-sign-compare
74-
xcheck_add_c_compiler_flag(/wd4267) # -Wno-shorten-64-to-32
75-
xcheck_add_c_compiler_flag(/wd4388) # -Wno-sign-compare
76-
xcheck_add_c_compiler_flag(/wd4389) # -Wno-sign-compare
77-
xcheck_add_c_compiler_flag(/wd4456) # Hides previous local declaration
78-
xcheck_add_c_compiler_flag(/wd4457) # Hides function parameter
79-
xcheck_add_c_compiler_flag(/wd4710) # Function not inlined
80-
xcheck_add_c_compiler_flag(/wd4711) # Function was inlined
81-
xcheck_add_c_compiler_flag(/wd4820) # Padding added after construct
82-
xcheck_add_c_compiler_flag(/wd4996) # -Wdeprecated-declarations
83-
xcheck_add_c_compiler_flag(/wd5045) # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
8467
endif()
8568

8669
# Set a 8MB default stack size on Windows.

amalgam.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const libunicode_c = loadFile("libunicode.c")
99
const libunicode_h = loadFile("libunicode.h")
1010
const libunicode_table_h = loadFile("libunicode-table.h")
1111
const list_h = loadFile("list.h")
12+
const msvc_pragmas_h = loadFile("msvc-pragmas.h")
1213
const quickjs_atom_h = loadFile("quickjs-atom.h")
1314
const quickjs_c = loadFile("quickjs.c")
1415
const quickjs_c_atomics_h = loadFile("quickjs-c-atomics.h")
@@ -23,6 +24,7 @@ const gen_builtin_array_fromasync_h = loadFile("builtin-array-fromasync.h")
2324
let source = "#if defined(QJS_BUILD_LIBC) && defined(__linux__) && !defined(_GNU_SOURCE)\n"
2425
+ "#define _GNU_SOURCE\n"
2526
+ "#endif\n"
27+
+ msvc_pragmas_h
2628
+ quickjs_c_atomics_h
2729
+ cutils_h
2830
+ list_h
@@ -40,6 +42,7 @@ let source = "#if defined(QJS_BUILD_LIBC) && defined(__linux__) && !defined(_GNU
4042
+ quickjs_libc_h
4143
+ quickjs_libc_c
4244
+ "#endif // QJS_BUILD_LIBC\n"
45+
source = source.replace(/#include "msvc-pragmas.h"/g, "")
4346
source = source.replace(/#include "quickjs-atom.h"/g, quickjs_atom_h)
4447
source = source.replace(/#include "quickjs-opcode.h"/g, quickjs_opcode_h)
4548
source = source.replace(/#include "libregexp-opcode.h"/g, libregexp_opcode_h)

cutils.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
* THE SOFTWARE.
2424
*/
25+
#include "msvc-pragmas.h"
2526
#include <assert.h>
2627
#include <stdlib.h>
2728
#include <stdio.h>

libregexp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
* THE SOFTWARE.
2323
*/
24+
#include "msvc-pragmas.h"
2425
#include <stdlib.h>
2526
#include <stdio.h>
2627
#include <stdarg.h>

libunicode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
* THE SOFTWARE.
2323
*/
24+
#include "msvc-pragmas.h"
2425
#include <stdlib.h>
2526
#include <stdio.h>
2627
#include <stdarg.h>

msvc-pragmas.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifdef _MSC_VER
2+
#pragma warning(disable: 4018) // -Wno-sign-conversion
3+
#pragma warning(disable: 4061) // -Wno-implicit-fallthrough
4+
#pragma warning(disable: 4100) // -Wno-unused-parameter
5+
#pragma warning(disable: 4200) // -Wno-zero-length-array
6+
#pragma warning(disable: 4242) // -Wno-shorten-64-to-32
7+
#pragma warning(disable: 4244) // -Wno-shorten-64-to-32
8+
#pragma warning(disable: 4245) // -Wno-sign-compare
9+
#pragma warning(disable: 4267) // -Wno-shorten-64-to-32
10+
#pragma warning(disable: 4388) // -Wno-sign-compare
11+
#pragma warning(disable: 4389) // -Wno-sign-compare
12+
#pragma warning(disable: 4456) // Hides previous local declaration
13+
#pragma warning(disable: 4457) // Hides function parameter
14+
#pragma warning(disable: 4710) // Function not inlined
15+
#pragma warning(disable: 4711) // Function was inlined
16+
#pragma warning(disable: 4820) // Padding added after construct
17+
#pragma warning(disable: 4996) // -Wdeprecated-declarations
18+
#pragma warning(disable: 5045) // Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
19+
#endif

qjs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
* THE SOFTWARE.
2424
*/
25+
#include "msvc-pragmas.h"
2526
#include <stdlib.h>
2627
#include <stdio.h>
2728
#include <stdarg.h>

qjsc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26+
#include "msvc-pragmas.h"
2627
#include <stdlib.h>
2728
#include <stdio.h>
2829
#include <stdarg.h>

quickjs-libc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
* THE SOFTWARE.
2424
*/
25+
#include "msvc-pragmas.h"
2526
#include "quickjs.h"
2627
#include <stdlib.h>
2728
#include <stdio.h>

quickjs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
* THE SOFTWARE.
2626
*/
27+
#include "msvc-pragmas.h"
2728
#include <stdlib.h>
2829
#include <stdio.h>
2930
#include <stdarg.h>

0 commit comments

Comments
 (0)