Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upDeprecate `object::borrowed`/`object::stolen` #771
Conversation
jagerman
requested a review
from
dean0x7d
Mar 28, 2017
jagerman
referenced this pull request
Mar 28, 2017
Closed
Unedfined symbol pybind11::object::borrowed #770
This comment has been minimized.
This comment has been minimized.
(Awaiting confirmation from #770 that this actually fixes it). |
This comment has been minimized.
This comment has been minimized.
One comment: In C++17 this could be fixed by adding just: inline constexpr object::borrowed_t object::borrowed;
inline constexpr object::stolen_t object::stolen; which is, of course, much nicer than the template hack, but seeing as we need the hack for 14/11 already, I don't see much advantage in using |
dean0x7d
reviewed
Mar 28, 2017
This looks too heavyweight. I would just replace all usages of |
This comment has been minimized.
This comment has been minimized.
I'm fine with that. Do you mean heavyweight in terms of added compiler complexity, or something else? (I did check that this doesn't change |
This comment has been minimized.
This comment has been minimized.
I mean complex both for the compiler and for humans. The only advantage is avoiding |
jagerman
force-pushed the
jagerman:borrowed-stolen-definition
branch
from
c1c5586
to
4a29ba8
Mar 28, 2017
jagerman
changed the title
Provide definitions of borrowed/stolen
Deprecated `object::borrowed`/`object::stolen`
Mar 28, 2017
jagerman
changed the title
Deprecated `object::borrowed`/`object::stolen`
Deprecate `object::borrowed`/`object::stolen`
Mar 28, 2017
This comment has been minimized.
This comment has been minimized.
Okay; updated the PR to deprecate |
This comment has been minimized.
This comment has been minimized.
Looks good to me. |
This comment has been minimized.
This comment has been minimized.
Looks good -- merged! |
jagerman commentedMar 28, 2017
•
edited
Provides (via a dummy template parameter hack) inline definitions of object::borrowed/object::stolen.The constexpr static instances can cause linking failures if the compiler doesn't optimize away the reference, as reported in #770.
There's no particularly nice way of fixing this in C++11/14: we can't inline definitions to match the declaration aren't permitted for non-templated static variables (C++17 does allows "inline" on variables, but that obviously doesn't help us.)
One solution that could work around it is to add an extra inherited subclass to
object
's hierarchy, but that's a bit of a messy solution and was decided against in #771 in favour of just deprecating (and eventually dropping) the constexpr statics.Fixes #770.