1. Python CFFI
  2. Untitled project
  3. cffi
  4. Issues
Issue #107 closed

Code genereated by cffi isn't warnings clean

Alex Gaynor
created an issue

When compiled at higher levels like -Wextra or -Wpedantic or -Weverything (some of these are GCC flags, some are clang, I forget which :/). This is an issue if you want to use -Werror to make sure you catch issues.

Comments (2)

  1. Casper Ti. Vector
    % cat test.py 
    import cffi
    ffi = cffi.FFI()
    ffi.set_source("_test", "", extra_compile_args = ["-Wpedantic"])
    ffi.cdef("extern void free (void *ptr);")
    ffi.compile()
    % python test.py
    _test.c: In function '_cffi_f_free':
    _test.c:322:6: warning: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic]
         ((Py_ssize_t(*)(CTypeDescrObject *, PyObject *, char **))_cffi_exports[23])
          ^
    _test.c:444:14: note: in expansion of macro '_cffi_prepare_pointer_call_argument'
       datasize = _cffi_prepare_pointer_call_argument(
                  ^
    _test.c:324:6: warning: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic]
         ((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[24])
          ^
    _test.c:451:9: note: in expansion of macro '_cffi_convert_array_from_object'
         if (_cffi_convert_array_from_object((char *)x0, _cffi_type(1), arg0) < 0)
             ^
    _test.c:302:6: warning: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic]
         ((void(*)(void))_cffi_exports[13])
          ^
    _test.c:456:3: note: in expansion of macro '_cffi_restore_errno'
       _cffi_restore_errno();
       ^
    _test.c:304:6: warning: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic]
         ((void(*)(void))_cffi_exports[14])
          ^
    _test.c:458:3: note: in expansion of macro '_cffi_save_errno'
       _cffi_save_errno();
       ^
    _test.c: At top level:
    _test.c:470:13: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
       { "free", (void *)_cffi_f_free, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_O, 0), (void *)_cffi_d_free },
                 ^
    _test.c:470:73: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
       { "free", (void *)_cffi_f_free, _CFFI_OP(_CFFI_OP_CPYTHON_BLTN_O, 0), (void *)_cffi_d_free },
    
  2. Log in to comment