Skip to content

Disable msvc warnings in source files #1111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,6 @@ if(MSVC)
xcheck_add_c_compiler_flag(-Wno-reserved-identifier)
xcheck_add_c_compiler_flag(-Wdeprecated-declarations)
xcheck_add_c_compiler_flag(/experimental:c11atomics)
xcheck_add_c_compiler_flag(/wd4018) # -Wno-sign-conversion
xcheck_add_c_compiler_flag(/wd4061) # -Wno-implicit-fallthrough
xcheck_add_c_compiler_flag(/wd4100) # -Wno-unused-parameter
xcheck_add_c_compiler_flag(/wd4200) # -Wno-zero-length-array
xcheck_add_c_compiler_flag(/wd4242) # -Wno-shorten-64-to-32
xcheck_add_c_compiler_flag(/wd4244) # -Wno-shorten-64-to-32
xcheck_add_c_compiler_flag(/wd4245) # -Wno-sign-compare
xcheck_add_c_compiler_flag(/wd4267) # -Wno-shorten-64-to-32
xcheck_add_c_compiler_flag(/wd4388) # -Wno-sign-compare
xcheck_add_c_compiler_flag(/wd4389) # -Wno-sign-compare
xcheck_add_c_compiler_flag(/wd4456) # Hides previous local declaration
xcheck_add_c_compiler_flag(/wd4457) # Hides function parameter
xcheck_add_c_compiler_flag(/wd4710) # Function not inlined
xcheck_add_c_compiler_flag(/wd4711) # Function was inlined
xcheck_add_c_compiler_flag(/wd4820) # Padding added after construct
xcheck_add_c_compiler_flag(/wd4996) # -Wdeprecated-declarations
xcheck_add_c_compiler_flag(/wd5045) # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
endif()

# Set a 8MB default stack size on Windows.
Expand Down
3 changes: 3 additions & 0 deletions amalgam.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const libunicode_c = loadFile("libunicode.c")
const libunicode_h = loadFile("libunicode.h")
const libunicode_table_h = loadFile("libunicode-table.h")
const list_h = loadFile("list.h")
const msvc_pragmas_h = loadFile("msvc-pragmas.h")
const quickjs_atom_h = loadFile("quickjs-atom.h")
const quickjs_c = loadFile("quickjs.c")
const quickjs_c_atomics_h = loadFile("quickjs-c-atomics.h")
Expand All @@ -23,6 +24,7 @@ const gen_builtin_array_fromasync_h = loadFile("builtin-array-fromasync.h")
let source = "#if defined(QJS_BUILD_LIBC) && defined(__linux__) && !defined(_GNU_SOURCE)\n"
+ "#define _GNU_SOURCE\n"
+ "#endif\n"
+ msvc_pragmas_h
+ quickjs_c_atomics_h
+ cutils_h
+ list_h
Expand All @@ -40,6 +42,7 @@ let source = "#if defined(QJS_BUILD_LIBC) && defined(__linux__) && !defined(_GNU
+ quickjs_libc_h
+ quickjs_libc_c
+ "#endif // QJS_BUILD_LIBC\n"
source = source.replace(/#include "msvc-pragmas.h"/g, "")
source = source.replace(/#include "quickjs-atom.h"/g, quickjs_atom_h)
source = source.replace(/#include "quickjs-opcode.h"/g, quickjs_opcode_h)
source = source.replace(/#include "libregexp-opcode.h"/g, libregexp_opcode_h)
Expand Down
1 change: 1 addition & 0 deletions api-test.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "msvc-pragmas.h"
#ifdef NDEBUG
#undef NDEBUG
#endif
Expand Down
1 change: 1 addition & 0 deletions cutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "msvc-pragmas.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
Expand Down
1 change: 1 addition & 0 deletions examples/fib.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "../msvc-pragmas.h"
#include "../quickjs.h"

#define countof(x) (sizeof(x) / sizeof((x)[0]))
Expand Down
1 change: 1 addition & 0 deletions examples/point.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "../msvc-pragmas.h"
#include "../quickjs.h"
#include <math.h>

Expand Down
1 change: 1 addition & 0 deletions libregexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "msvc-pragmas.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
Expand Down
1 change: 1 addition & 0 deletions libunicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "msvc-pragmas.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
Expand Down
19 changes: 19 additions & 0 deletions msvc-pragmas.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifdef _MSC_VER
#pragma warning(disable: 4018) // -Wno-sign-conversion
#pragma warning(disable: 4061) // -Wno-implicit-fallthrough
#pragma warning(disable: 4100) // -Wno-unused-parameter
#pragma warning(disable: 4200) // -Wno-zero-length-array
#pragma warning(disable: 4242) // -Wno-shorten-64-to-32
#pragma warning(disable: 4244) // -Wno-shorten-64-to-32
#pragma warning(disable: 4245) // -Wno-sign-compare
#pragma warning(disable: 4267) // -Wno-shorten-64-to-32
#pragma warning(disable: 4388) // -Wno-sign-compare
#pragma warning(disable: 4389) // -Wno-sign-compare
#pragma warning(disable: 4456) // Hides previous local declaration
#pragma warning(disable: 4457) // Hides function parameter
#pragma warning(disable: 4710) // Function not inlined
#pragma warning(disable: 4711) // Function was inlined
#pragma warning(disable: 4820) // Padding added after construct
#pragma warning(disable: 4996) // -Wdeprecated-declarations
#pragma warning(disable: 5045) // Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
#endif
1 change: 1 addition & 0 deletions qjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "msvc-pragmas.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
Expand Down
1 change: 1 addition & 0 deletions qjsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "msvc-pragmas.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
Expand Down
1 change: 1 addition & 0 deletions quickjs-libc.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "msvc-pragmas.h"
#include "quickjs.h"
#include <stdlib.h>
#include <stdio.h>
Expand Down
1 change: 1 addition & 0 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "msvc-pragmas.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
Expand Down
1 change: 1 addition & 0 deletions run-test262.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "msvc-pragmas.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
Expand Down
Loading