Skip to content

Incompatible with MSVC: initializer is not a constant #1275

@kdada

Description

@kdada

The INFINITY macro and 1.0 / 0.0 are not constants in MSVC and need to be corrected for global.Infinity, number.NEGATIVE_INFINITY, and number.POSITIVE_INFINITY.

As shown below:

static const JSCFunctionListEntry js_number_funcs[] = {
-    JS_PROP_DOUBLE_DEF("NEGATIVE_INFINITY", -INFINITY, 0 ),
-    JS_PROP_DOUBLE_DEF("POSITIVE_INFINITY", INFINITY, 0 ),
+    JS_PROP_U2D_DEF("NEGATIVE_INFINITY", 0xFFF0ull<<48, 0 ), // workaround for msvc
+    JS_PROP_U2D_DEF("POSITIVE_INFINITY", 0x7FF0ull<<48, 0 ), // workaround for msvc
};

static const JSCFunctionListEntry js_global_funcs[] = {
-    JS_PROP_DOUBLE_DEF("Infinity", 1.0 / 0.0, 0 ),
+    JS_PROP_U2D_DEF("Infinity", 0x7FF0ull<<48, 0 ), // workaround for msvc
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions