Skip to content

Fix compilation issues with GCC and -Wextra #131

@saghul

Description

@saghul
/home/saghul/src/quickjs/examples/../quickjs.h: In function ‘JS_NewCFunctionMagic’:
/home/saghul/src/quickjs/examples/../quickjs.h:919:34: error: cast between incompatible function types from ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *, int)’ to ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *)’ [-Werror=cast-function-type]
  919 |     return JS_NewCFunction2(ctx, (JSCFunction *)func, name, length, cproto, magic);
      |                                  ^
/home/saghul/src/quickjs/examples/../quickjs.h:919:34: error: cast between incompatible function types from ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *, int)’ to ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *)’ [-Werror=cast-function-type]
  919 |     return JS_NewCFunction2(ctx, (JSCFunction *)func, name, length, cproto, magic);
      |                                  ^
In file included from /home/saghul/src/quickjs/tests/../quickjs-libc.h:30,
                 from /home/saghul/src/quickjs/tests/bjson.c:24:
/home/saghul/src/quickjs/tests/../quickjs.h: In function ‘JS_NewCFunctionMagic’:
/home/saghul/src/quickjs/tests/../quickjs.h:919:34: error: cast between incompatible function types from ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *, int)’ to ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *)’ [-Werror=cast-function-type]
  919 |     return JS_NewCFunction2(ctx, (JSCFunction *)func, name, length, cproto, magic);
      |                                  ^
cc1: all warnings being treated as errors
make[3]: *** [CMakeFiles/bjson.dir/build.make:79: CMakeFiles/bjson.dir/tests/bjson.c.o] Error 1
make[3]: Leaving directory '/home/saghul/src/quickjs/build'
make[2]: *** [CMakeFiles/Makefile2:342: CMakeFiles/bjson.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
In file included from /home/saghul/src/quickjs/quickjs.c:47:
/home/saghul/src/quickjs/quickjs.h: In function ‘JS_NewCFunctionMagic’:
/home/saghul/src/quickjs/quickjs.h:919:34: error: cast between incompatible function types from ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *, int)’ to ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *)’ [-Werror=cast-function-type]
  919 |     return JS_NewCFunction2(ctx, (JSCFunction *)func, name, length, cproto, magic);
      |                                  ^
cc1: all warnings being treated as errors
make[3]: *** [CMakeFiles/fib.dir/build.make:79: CMakeFiles/fib.dir/examples/fib.c.o] Error 1
make[3]: Leaving directory '/home/saghul/src/quickjs/build'
make[2]: *** [CMakeFiles/Makefile2:290: CMakeFiles/fib.dir/all] Error 2
cc1: all warnings being treated as errors
make[3]: *** [CMakeFiles/point.dir/build.make:79: CMakeFiles/point.dir/examples/point.c.o] Error 1
make[3]: Leaving directory '/home/saghul/src/quickjs/build'
make[2]: *** [CMakeFiles/Makefile2:316: CMakeFiles/point.dir/all] Error 2
/home/saghul/src/quickjs/quickjs.c: In function ‘js_append_enumerate’:
/home/saghul/src/quickjs/quickjs.c:13534:40: error: cast between incompatible function types from ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *, int)’ to ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *)’ [-Werror=cast-function-type]
13534 |                                        (JSCFunction *)js_create_array_iterator,
      |                                        ^
/home/saghul/src/quickjs/quickjs.c:13547:37: error: cast between incompatible function types from ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *, BOOL *, int)’ {aka ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *, int *, int)’} to ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *)’ [-Werror=cast-function-type]
13547 |     &&  JS_IsCFunction(ctx, method, (JSCFunction *)js_array_iterator_next, 0)
      |                                     ^
/home/saghul/src/quickjs/quickjs.c: In function ‘add_import’:
/home/saghul/src/quickjs/quickjs.c:26366:55: error: implicit conversion from ‘enum <anonymous>’ to ‘JSVarKindEnum’ [-Werror=enum-conversion]
26366 |                               local_name, TRUE, TRUE, FALSE);
      |                                                       ^~~~~
/home/saghul/src/quickjs/quickjs.c: In function ‘add_module_variables’:
/home/saghul/src/quickjs/quickjs.c:30165:45: error: implicit conversion from ‘enum <anonymous>’ to ‘JSVarKindEnum’ [-Werror=enum-conversion]
30165 |                             hf->is_lexical, FALSE) < 0)
      |                                             ^~~~~
/home/saghul/src/quickjs/quickjs.c: In function ‘JS_AddIntrinsicPromise’:
/home/saghul/src/quickjs/quickjs.c:45610:34: error: cast between incompatible function types from ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *, int)’ to ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *)’ [-Werror=cast-function-type]
45610 |     obj1 = JS_NewCFunction3(ctx, (JSCFunction *)js_function_constructor,
      |                                  ^
/home/saghul/src/quickjs/quickjs.c:45646:34: error: cast between incompatible function types from ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *, int)’ to ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *)’ [-Werror=cast-function-type]
45646 |     obj1 = JS_NewCFunction3(ctx, (JSCFunction *)js_function_constructor,
      |                                  ^
/home/saghul/src/quickjs/quickjs.c: In function ‘JS_AddIntrinsicBaseObjects’:
/home/saghul/src/quickjs/quickjs.c:47187:42: error: cast between incompatible function types from ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *, int)’ to ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *)’ [-Werror=cast-function-type]
47187 |         func_obj = JS_NewCFunction3(ctx, (JSCFunction *)js_error_constructor,
      |                                          ^
/home/saghul/src/quickjs/quickjs.c: In function ‘JS_AddIntrinsicTypedArrays’:
/home/saghul/src/quickjs/quickjs.c:50359:42: error: cast between incompatible function types from ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *, int)’ to ‘JSValue (*)(JSContext *, JSValue,  int,  JSValue *)’ [-Werror=cast-function-type]
50359 |         func_obj = JS_NewCFunction3(ctx, (JSCFunction *)js_typed_array_constructor,
      |                                          ^
/home/saghul/src/quickjs/quickjs.c: In function ‘js_json_check’:
/home/saghul/src/quickjs/quickjs.c:41843:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
41843 |         if (JS_IsFunction(ctx, val))
      |            ^
/home/saghul/src/quickjs/quickjs.c:41845:5: note: here
41845 |     case JS_TAG_STRING:
      |     ^~~~
cc1: all warnings being treated as errors

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