Skip to content

Commit 47c9957

Browse files
committed
fix for MSVC
1 parent 96fdd79 commit 47c9957

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

quickjs/quickjs.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,18 @@ typedef struct JSValue {
215215
#define JS_VALUE_GET_FLOAT64(v) ((v).u.float64)
216216
#define JS_VALUE_GET_PTR(v) ((v).u.ptr)
217217

218+
#ifdef __cplusplus
219+
#define JS_MKVAL(tag, val) JSValue{ JSValueUnion{ .int32 = val }, tag }
220+
#define JS_MKPTR(tag, p) JSValue{ JSValueUnion{ .ptr = p }, tag }
221+
#define JS_NAN JSValue{ .u.float64 = JS_FLOAT64_NAN, JS_TAG_FLOAT64 }
222+
#else
218223
#define JS_MKVAL(tag, val) (JSValue){ (JSValueUnion){ .int32 = val }, tag }
219224
#define JS_MKPTR(tag, p) (JSValue){ (JSValueUnion){ .ptr = p }, tag }
225+
#define JS_NAN (JSValue){ .u.float64 = JS_FLOAT64_NAN, JS_TAG_FLOAT64 }
226+
#endif
220227

221228
#define JS_TAG_IS_FLOAT64(tag) ((unsigned)(tag) == JS_TAG_FLOAT64)
222229

223-
#define JS_NAN (JSValue){ .u.float64 = JS_FLOAT64_NAN, JS_TAG_FLOAT64 }
224230

225231
static inline JSValue __JS_NewFloat64(JSContext *ctx, double d)
226232
{

0 commit comments

Comments
 (0)