forked from AcademySoftwareFoundation/OpenColorIO
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix build of Python bindings with GCC 8 (AcademySoftwareFoundation#518)
GCC 8 appears to be rather stricter about various issues to do with type conversions and casts than GCC 7 was. This affects OpenColorIO's Python bindings quite heavily, producing a large number of warnings (which are converted to errors by `-Werror`) and outright errors. The changes here are almost all one of three basic types: 1. Many functions that become Python methods with no arguments (using the METH_NOARGS flag) did not include the expected second parameter in their signatures at all. METH_NOARGS does not prevent this second parameter being passed *at all*, it only ensures that it will always be NULL. It's still not technically correct to leave it out of the function signature; as a comment from 'yak' on https://stackoverflow.com/questions/10256315 points out, there are situations where this could cause a crash. I've added the second parameter (with no name, per convention) to every one of these cases. 2. In several cases, classes specified a custom destructor, with a cast to the `destructor` type, which only takes a single parameter. However, the signatures for these destructor functions included two parameters, assuming that they'd get an 'args' parameter (they do not). I've corrected all these cases. 3. In several cases, classes specified custom str or repr methods. However, in the `PyTypeObject` structures for these classes, these methods were not cast to the `reprfunc` type, as they ought to be. I've added these casts. There are two warnings I just can't get rid of with my limited C++ knowledge. The `Config` class (in PyConfig.cpp) defines a couple of methods that take kwargs as well as args. This is done by setting the `METH_KEYWORDS` flag, which ultimately seems to result in a cast from type `PyCFunctionWithKeywords` to `PyCFunction` happening somewhere behind the scenes. There's some discussion of this at https://stackoverflow.com/questions/9496753 GCC 8 does not like this cast - it causes a 'cast-function-type' warning. I've messed around a bit with `reinterpret_cast` and stuff, but didn't really understand precisely what I was doing and didn't manage to find anything that got rid of the warnings. So I just suppressed these warnings with GCC pragmas instead (using `-Wno-error=cast-function-type` causes older GCC versions to choke, so we can't do that). I've tested at least that the compilation succeeds, and I can import the Python module and instantiate a few classes and examine their docstrings and stuff with no apparent errors. Many thanks to Kevin Kofler for his help with these fixes. Signed-off-by: Adam Williamson <awilliam@redhat.com>
- Loading branch information
Showing
20 changed files
with
272 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.