-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[QUESTION] Function with pointer to pointer arg #2812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yes. pybind11 does not support pointers to pointers to something. What type would you expect that to be on the Python side? |
@YannickJadoul I would expect a class instance on the python side. Also is there any temporary workaround for that? |
No, but ... why would you have a pointer to a pointer to a class just give you a class? That doesn't really make sense. A workaround, yes: just accept an object of a class by value, reference, or pointer, and pass it on to the function that's expecting a pointer to pointer. |
One minor pain point I've ran into is wrapping calls to We've worked around in Drake, but it ain't pretty. Example (older fork of pybind11, so you'll need to munge the names): |
@YannickJadoul If I accept an object then the methods signature is changed hence I cannot override the method in the trampoline class. This is what I did: Status NewLogger(const std::string &fname, Logger *result) override {
PYBIND11_OVERRIDE_PURE(
Status, /* Return type */
Env, /* Parent class */
NewLogger, /* Name of function in C++ (must match Python name) */
fname, result);
} Error while compiling: ./leveldb/leveldb.cpp(233): error C3668: 'PyEnv::NewLogger': method with override specifier 'override' did not
override any base class methods It would be helpful if you could provide a snippet for the method, for better clarification. |
@kumaraditya303, right, so you'll have to wrap that function in the trampoline class and forward calls to the actual hierarchy, somehow, and you probably can't use But again, |
I am writing a Trampoline class for leveldb Env Class https://github.com/google/leveldb/blob/master/include/leveldb/env.h
Compiler:
Copyright (C) Microsoft Corporation. All rights reserved.
16.8.3.61104
But it errors out while compiling with error:
It seems it is erroring due to c++
** args
The text was updated successfully, but these errors were encountered: