fix compile bug under clang(backend MSVC)
This commit is contained in:
parent
6868fb9e25
commit
7be64d0df7
3 changed files with 18 additions and 8 deletions
|
@ -21,6 +21,17 @@ endif()
|
|||
message(STATUS "Building in ${CMAKE_BUILD_TYPE} mode")
|
||||
message(STATUS "Building with ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION} on ${CMAKE_SYSTEM}")
|
||||
|
||||
function(IsMSVC var)
|
||||
if (MSVC OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_SIMULATE_ID STREQUAL "MSVC"))
|
||||
set(${var} 1 PARENT_SCOPE)
|
||||
else()
|
||||
set(${var} 0 PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
set(is_msvc 0)
|
||||
IsMSVC(is_msvc)
|
||||
|
||||
macro(xcheck_add_c_compiler_flag FLAG)
|
||||
string(REPLACE "-" "" FLAG_NO_HYPHEN ${FLAG})
|
||||
check_c_compiler_flag(${FLAG} COMPILER_SUPPORTS_${FLAG_NO_HYPHEN})
|
||||
|
@ -30,7 +41,7 @@ macro(xcheck_add_c_compiler_flag FLAG)
|
|||
endmacro()
|
||||
|
||||
xcheck_add_c_compiler_flag(-Wall)
|
||||
if(NOT MSVC)
|
||||
if(NOT is_msvc)
|
||||
xcheck_add_c_compiler_flag(-Werror)
|
||||
xcheck_add_c_compiler_flag(-Wextra)
|
||||
endif()
|
||||
|
@ -45,7 +56,7 @@ xcheck_add_c_compiler_flag(-Wno-format-truncation)
|
|||
xcheck_add_c_compiler_flag(-funsigned-char)
|
||||
|
||||
# ClangCL is command line compatible with MSVC, so 'MSVC' is set.
|
||||
if(MSVC)
|
||||
if(${is_msvc})
|
||||
xcheck_add_c_compiler_flag(-Wno-unsafe-buffer-usage)
|
||||
xcheck_add_c_compiler_flag(-Wno-sign-conversion)
|
||||
xcheck_add_c_compiler_flag(-Wno-nonportable-system-include-path)
|
||||
|
@ -54,7 +65,7 @@ if(MSVC)
|
|||
xcheck_add_c_compiler_flag(-Wno-reserved-macro-identifier)
|
||||
xcheck_add_c_compiler_flag(-Wno-reserved-identifier)
|
||||
xcheck_add_c_compiler_flag(-Wdeprecated-declarations)
|
||||
add_compile_definitions(WIN32_LEAN_AND_MEAN)
|
||||
add_compile_definitions(WIN32_LEAN_AND_MEAN _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
|
@ -146,7 +157,7 @@ if(BUILD_QJS_LIBC)
|
|||
endif()
|
||||
list(APPEND qjs_defines _GNU_SOURCE)
|
||||
list(APPEND qjs_libs qjs ${CMAKE_DL_LIBS})
|
||||
if(NOT MSVC)
|
||||
if(NOT is_msvc)
|
||||
list(APPEND qjs_libs m pthread)
|
||||
endif()
|
||||
|
||||
|
|
1
cutils.c
1
cutils.c
|
@ -612,6 +612,7 @@ void rqsort(void *base, size_t nmemb, size_t size, cmp_f cmp, void *opaque)
|
|||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
struct timezone;
|
||||
// From: https://stackoverflow.com/a/26085827
|
||||
static int gettimeofday_msvc(struct timeval *tp, struct timezone *tzp)
|
||||
{
|
||||
|
|
|
@ -211,8 +211,6 @@ typedef enum {
|
|||
JS_GC_PHASE_REMOVE_CYCLES,
|
||||
} JSGCPhaseEnum;
|
||||
|
||||
typedef enum OPCodeEnum OPCodeEnum;
|
||||
|
||||
struct JSRuntime {
|
||||
JSMallocFunctions mf;
|
||||
JSMallocState malloc_state;
|
||||
|
@ -977,7 +975,7 @@ typedef enum OPCodeFormat {
|
|||
#undef FMT
|
||||
} OPCodeFormat;
|
||||
|
||||
enum OPCodeEnum {
|
||||
typedef enum OPCodeEnum {
|
||||
#define FMT(f)
|
||||
#define DEF(id, size, n_pop, n_push, f) OP_ ## id,
|
||||
#define def(id, size, n_pop, n_push, f)
|
||||
|
@ -997,7 +995,7 @@ enum OPCodeEnum {
|
|||
#undef DEF
|
||||
#undef FMT
|
||||
OP_TEMP_END,
|
||||
};
|
||||
} OPCodeEnum;
|
||||
|
||||
static int JS_InitAtoms(JSRuntime *rt);
|
||||
static JSAtom __JS_NewAtomInit(JSRuntime *rt, const char *str, int len,
|
||||
|
|
Loading…
Reference in a new issue