cesanta / mjs

Embedded JavaScript engine for C/C++
https://mongoose-os.com
Other
1.9k stars 172 forks source link

built under wdk 7600.1 64 bit, got error "'uintptr_t' : redefinition" #152

Open shajunxing opened 4 years ago

shajunxing commented 4 years ago

In higher version of msvc, default crt changed from msvcrt.dll to ucrtbase.dll(not sure, i checked using dependency walker), mjs's ffi still using the former, see mjs_ffi.c line 1164, and seems dlsym() first argument "void *handle" is not used(therefore we cannot specify which dll to load, why?) So i switched to windows driver kit 7600 instead of msvc because wdk links to msvcrt.dll by default. I built 64 bit version and got the error in title. I checked the source code and found in mjs_internal.h line 64, "typedef unsigned long uintptr_t;" is not correct because "long" is 32 bit. I change it to "

#ifdef _WIN64
typedef uint64_t uintptr_t;
#else
typedef uint32_t uintptr_t;
#endif

" I'm not very good at c/c++ but seems this is more strict? Also I found in mjs_core_public.h from line 12 to 14 there are several same type definitions as in mjs_internal.h, could you please put them together into one place?

shajunxing commented 4 years ago

Whole definition is


#if !defined(_MSC_VER) || _MSC_VER >= 1700
#include <stdint.h>
#else
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#ifdef _WIN64
typedef uint64_t uintptr_t;
#else
typedef uint32_t uintptr_t;
#endif
#endif
shajunxing commented 4 years ago

frozen.h line 30 #if defined(_WIN32) && _MSC_VER < 1700 should be #if defined(_MSC_VER) && _MSC_VER < 1700 or error under mingw, maybe even if _MSC_VER not defined _MSC_VER < 1700 still returns true? I searched whole project using definition like if defined(...) && ... and found some are correct some are not.