Skip to content

Incompatible function type building pasteboard._native #22

@xdgc

Description

@xdgc

Firstly I want to acknowledge that Toby is not actively maintaining pasteboard, but I do want to document this issue in case others have it.

I'm on a new Mac, and am reinstalling all the things. I'm on macOS 15.5 (Sequoia), and just installed Homebrew. However I get errors building pasteboard on either Apple Python or Homebrew's.

      building 'pasteboard._native' extension
      gcc -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk -I/opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c src/pasteboard/pasteboard.m -o build/temp.macosx-15.0-arm64-cpython-312/src/pasteboard/pasteboard.o -Wall -Wextra -Wpedantic -Werror
      src/pasteboard/pasteboard.m:325:9: error: cast from 'PyObject *(*)(PyObject *, PyObject *, PyObject *)' (aka 'struct _object *(*)(struct _object *, struct _object *, struct _object *)') to 'PyCFunction' (aka 'struct _object *(*)(struct _object *, struct _object *)') converts to incompatible function type [-Werror,-Wcast-function-type-mismatch]
        325 |         (PyCFunction)pasteboard_get_contents,
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      src/pasteboard/pasteboard.m:331:9: error: cast from 'PyObject *(*)(PyObject *, PyObject *, PyObject *)' (aka 'struct _object *(*)(struct _object *, struct _object *, struct _object *)') to 'PyCFunction' (aka 'struct _object *(*)(struct _object *, struct _object *)') converts to incompatible function type [-Werror,-Wcast-function-type-mismatch]
        331 |         (PyCFunction)pasteboard_set_contents,
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      src/pasteboard/pasteboard.m:337:9: error: cast from 'PyObject *(*)(PyObject *, PyObject *, PyObject *)' (aka 'struct _object *(*)(struct _object *, struct _object *, struct _object *)') to 'PyCFunction' (aka 'struct _object *(*)(struct _object *, struct _object *)') converts to incompatible function type [-Werror,-Wcast-function-type-mismatch]
        337 |         (PyCFunction)pasteboard_get_file_urls,
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      3 errors generated.
      error: command '/usr/bin/gcc' failed with exit code 1

From minimal research I believe that the cast to PyCFunction is correct per the Python API specification, but that gcc/clang is overly complainy about it because a PyCFunctionWithKeywords is a valid implementation for this method table.

I "solved" the problem by adding "-Wno-cast-function-type-mismatch" to the end of setup.py's extra_compile_args, superseding the macro warn options.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions