Skip to content

[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

Closed
kumaraditya303 opened this issue Jan 20, 2021 · 6 comments
Closed

[QUESTION] Function with pointer to pointer arg #2812

kumaraditya303 opened this issue Jan 20, 2021 · 6 comments

Comments

@kumaraditya303
Copy link
Contributor

I am writing a Trampoline class for leveldb Env Class https://github.com/google/leveldb/blob/master/include/leveldb/env.h

class PyEnv : Env
{

public:
    using Env::Env;
    Status NewSequentialFile(const std::string &fname,
                             SequentialFile **result) override
    {
        PYBIND11_OVERRIDE_PURE(
            Status,            /* Return type */
            Env,               /* Parent class */
            NewSequentialFile, /* Name of function in C++ (must match Python name) */
            fname,
            result /* Argument(s) */
        );
    }
    Status NewRandomAccessFile(const std::string &fname,
                               RandomAccessFile **result) override
    {
        PYBIND11_OVERRIDE_PURE(
            Status,              /* Return type */
            Env,                 /* Parent class */
            NewRandomAccessFile, /* Name of function in C++ (must match Python name) */
            fname,
            result /* Argument(s) */
        );
    }
    Status NewWritableFile(const std::string &fname,
                           WritableFile **result) override
    {
        PYBIND11_OVERRIDE_PURE(
            Status,          /* Return type */
            Env,             /* Parent class */
            NewWritableFile, /* Name of function in C++ (must match Python name) */
            fname,
            result /* Argument(s) */
        );
    }
    Status NewAppendableFile(const std::string &fname,
                             WritableFile **result) override
    {
        PYBIND11_OVERRIDE_PURE(
            Status,            /* Return type */
            Env,               /* Parent class */
            NewAppendableFile, /* Name of function in C++ (must match Python name) */
            fname,
            result /* Argument(s) */
        );
    }
    bool FileExists(const std::string &fname) override
    {
        PYBIND11_OVERRIDE_PURE(
            bool,       /* Return type */
            Env,        /* Parent class */
            FileExists, /* Name of function in C++ (must match Python name) */
            fname);
    }
    Status GetChildren(const std::string &dir,
                       std::vector<std::string> *result) override
    {
        PYBIND11_OVERRIDE_PURE(
            Status,      /* Return type */
            Env,         /* Parent class */
            GetChildren, /* Name of function in C++ (must match Python name) */
            dir,
            result);
    }
    Status RemoveFile(const std::string &fname) override
    {
        PYBIND11_OVERRIDE_PURE(
            Status,     /* Return type */
            Env,        /* Parent class */
            RemoveFile, /* Name of function in C++ (must match Python name) */
            fname);
    }
    Status DeleteFile(const std::string &fname) override
    {
        PYBIND11_OVERRIDE_PURE(
            Status,     /* Return type */
            Env,        /* Parent class */
            DeleteFile, /* Name of function in C++ (must match Python name) */
            fname);
    }
    Status CreateDir(const std::string &dirname) override
    {
        PYBIND11_OVERRIDE_PURE(
            Status,    /* Return type */
            Env,       /* Parent class */
            CreateDir, /* Name of function in C++ (must match Python name) */
            dirname);
    }
    Status RemoveDir(const std::string &dirname) override
    {
        PYBIND11_OVERRIDE_PURE(
            Status,    /* Return type */
            Env,       /* Parent class */
            RemoveDir, /* Name of function in C++ (must match Python name) */
            dirname);
    }
    Status DeleteDir(const std::string &dirname) override
    {
        PYBIND11_OVERRIDE_PURE(
            Status,    /* Return type */
            Env,       /* Parent class */
            DeleteDir, /* Name of function in C++ (must match Python name) */
            dirname);
    }
    Status GetFileSize(const std::string &fname, uint64_t *file_size) override
    {
        PYBIND11_OVERRIDE_PURE(
            Status,      /* Return type */
            Env,         /* Parent class */
            GetFileSize, /* Name of function in C++ (must match Python name) */
            fname,
            file_size);
    }
    Status RenameFile(const std::string &src,
                      const std::string &target) override
    {
        PYBIND11_OVERRIDE_PURE(
            Status,     /* Return type */
            Env,        /* Parent class */
            RenameFile, /* Name of function in C++ (must match Python name) */
            src,
            target);
    }
    Status LockFile(const std::string &fname, FileLock **lock) override
    {
        PYBIND11_OVERRIDE_PURE(
            Status,   /* Return type */
            Env,      /* Parent class */
            LockFile, /* Name of function in C++ (must match Python name) */
            fname,
            lock);
    }
    Status UnlockFile(FileLock *lock) override
    {
        PYBIND11_OVERRIDE_PURE(
            Status,     /* Return type */
            Env,        /* Parent class */
            UnlockFile, /* Name of function in C++ (must match Python name) */
            lock);
    }
    void Schedule(void (*function)(void *arg), void *arg) override
    {
        PYBIND11_OVERRIDE_PURE(
            void,     /* Return type */
            Env,      /* Parent class */
            Schedule, /* Name of function in C++ (must match Python name) */
            function,
            arg,
            arg);
    }
    void StartThread(void (*function)(void *arg), void *arg) override
    {
        PYBIND11_OVERRIDE_PURE(
            void,        /* Return type */
            Env,         /* Parent class */
            StartThread, /* Name of function in C++ (must match Python name) */
            function,
            arg,
            arg);
    }
    Status GetTestDirectory(std::string *path) override
    {
        PYBIND11_OVERRIDE_PURE(
            Status,           /* Return type */
            Env,              /* Parent class */
            GetTestDirectory, /* Name of function in C++ (must match Python name) */
            path);
    }
    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);
    }
    uint64_t NowMicros() override
    {
        PYBIND11_OVERRIDE_PURE(
            uint64_t,     /* Return type */
            Env,          /* Parent class */
            NowMicros, ); /* Name of function in C++ (must match Python name) */
    }
    void SleepForMicroseconds(int micros) override
    {
        PYBIND11_OVERRIDE_PURE(
            void, /* Return type */
            Env,  /* Parent class */
            SleepForMicroseconds,
            micros);
    }
};

Compiler:
Copyright (C) Microsoft Corporation. All rights reserved.

16.8.3.61104
But it errors out while compiling with error:

running build_ext
building 'leveldb' extension
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I./third_party/leveldb/include/ -I./third_party/leveldb/port/ -I./third_party/leveldb/util/ -I./third_party/leveldb/ -I./third_party/snappy/ -I./third_party/snappy/build/ -I./third_party/pybind11/include/ -IC:\Users\Kumar Aditya\AppData\Local\Programs\Python\Python39\include -IC:\Users\Kumar Aditya\AppData\Local\Programs\Python\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt /EHsc /Tp./leveldb/leveldb.cpp /Fobuild\temp.win-amd64-3.9\Release\./leveldb/leveldb.obj -DSNAPPY -DLEVELDB_PLATFORM_WINDOWS
leveldb.cpp
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(870): warning C4180: qualifier applied to function type has no meaning; ignored
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(946): note: see reference to class template instantiation 'pybind11::detail::type_caster_base<type>' being compiled
        with
        [
            type=void (const leveldb::Slice &,void *)
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(1996): note: see reference to class template instantiation 'pybind11::detail::type_caster<void (const leveldb::Slice &,void *),void>' being compiled
./third_party/pybind11/include/pybind11/pybind11.h(166): note: see reference to class template instantiation 'pybind11::detail::argument_loader<Class *,const leveldb::Slice &,void *,size_t,void (__cdecl *)(const leveldb::Slice &,void *)>' being compiled
        with
        [
            Class=leveldb::Cache
        ]
./third_party/pybind11/include/pybind11/pybind11.h(85): note: see reference to function template instantiation 'void pybind11::cpp_function::initialize<pybind11::cpp_function::{ctor}::<lambda_7ea5e8ab80bc2d73cc10c3d37f9940e8>,Return,Class*,const leveldb::Slice&,void*,size_t,void(__cdecl *)(const leveldb::Slice &,void *),pybind11::name,pybind11::is_method,pybind11::sibling,pybind11::return_value_policy>(Func &&,Return (__cdecl *)(Class *,const leveldb::Slice &,void *,size_t,void (__cdecl *)(const leveldb::Slice &,void *)),const pybind11::name &,const pybind11::is_method &,const pybind11::sibling &,const pybind11::return_value_policy &)' being compiled
        with
        [
            Return=leveldb::Cache::Handle *,
            Class=leveldb::Cache,
            Func=pybind11::cpp_function::{ctor}::<lambda_7ea5e8ab80bc2d73cc10c3d37f9940e8>
        ]
./third_party/pybind11/include/pybind11/pybind11.h(1317): note: see reference to function template instantiation 'pybind11::cpp_function::cpp_function<Return,leveldb::Cache,const leveldb::Slice&,void*,size_t,void(__cdecl *)(const leveldb::Slice &,void *),pybind11::name,pybind11::is_method,pybind11::sibling,pybind11::return_value_policy>(Return (__cdecl leveldb::Cache::* )(const leveldb::Slice &,void *,size_t,void (__cdecl *)(const leveldb::Slice &,void *)),const pybind11::name &,const pybind11::is_method &,const pybind11::sibling &,const pybind11::return_value_policy &)' being compiled
        with
        [
            Return=leveldb::Cache::Handle *
        ]
./leveldb/leveldb.cpp(409): note: see reference to function template instantiation 'pybind11::class_<leveldb::Cache,PyCache> &pybind11::class_<leveldb::Cache,PyCache>::def<leveldb::Cache::Handle*(__cdecl leveldb::Cache::* )(const leveldb::Slice &,void *,size_t,void (__cdecl *)(const leveldb::Slice &,void *)),pybind11::return_value_policy>(const char *,Func &&,const pybind11::return_value_policy &)' being compiled
        with
        [
            Func=leveldb::Cache::Handle *(__cdecl leveldb::Cache::* )(const leveldb::Slice &,void *,size_t,void (__cdecl *)(const leveldb::Slice &,void *))
        ]
./leveldb/leveldb.cpp(418): note: see reference to function template instantiation 'pybind11::class_<leveldb::Cache,PyCache> &pybind11::class_<leveldb::Cache,PyCache>::def<leveldb::Cache::Handle*(__cdecl leveldb::Cache::* )(const leveldb::Slice &,void *,size_t,void (__cdecl *)(const leveldb::Slice &,void *)),pybind11::return_value_policy>(const char *,Func &&,const pybind11::return_value_policy &)' being compiled
        with
        [
            Func=leveldb::Cache::Handle *(__cdecl leveldb::Cache::* )(const leveldb::Slice &,void *,size_t,void (__cdecl *)(const leveldb::Slice &,void *))
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(883): warning C4180: qualifier applied to function type has no meaning; ignored
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(904): warning C4180: qualifier applied to function type has no meaning; ignored
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(911): warning C4180: qualifier applied to function type has no meaning; ignored
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(1836): error C2665: 'pybind11::detail::type_caster_base<type>::cast': none of the 3 overloads could convert all the argument types
        with
        [
            type=leveldb::SequentialFile
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(904): note: could be 'pybind11::handle pybind11::detail::type_caster_base<type>::cast(const leveldb::SequentialFile *,pybind11::return_value_policy,pybind11::handle)'
        with
        [
            type=leveldb::SequentialFile
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(876): note: or       'pybind11::handle pybind11::detail::type_caster_base<type>::cast(leveldb::SequentialFile &&,pybind11::return_value_policy,pybind11::handle)'
        with
        [
            type=leveldb::SequentialFile
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(870): note: or       'pybind11::handle pybind11::detail::type_caster_base<type>::cast(const leveldb::SequentialFile &,pybind11::return_value_policy,pybind11::handle)'
        with
        [
            type=leveldb::SequentialFile
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(1838): note: while trying to match the argument list '(leveldb::SequentialFile **, pybind11::return_value_policy, nullptr)'
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2045): note: see reference to function template instantiation 'pybind11::tuple pybind11::make_tuple<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::SequentialFile**&>(const std::string &,leveldb::SequentialFile **&)' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2199): note: see reference to function template instantiation 'pybind11::detail::simple_collector<pybind11::return_value_policy::automatic_reference>::simple_collector<const std::string&,leveldb::SequentialFile**&>(const std::string &,leveldb::SequentialFile **&)' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2199): note: see reference to function template instantiation 'pybind11::detail::simple_collector<pybind11::return_value_policy::automatic_reference>::simple_collector<const std::string&,leveldb::SequentialFile**&>(const std::string &,leveldb::SequentialFile **&)' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2219): note: see reference to function template instantiation 'pybind11::detail::simple_collector<pybind11::return_value_policy::automatic_reference> pybind11::detail::collect_arguments<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::SequentialFile**&,void>(const std::string &,leveldb::SequentialFile **&)' being compiled
./leveldb/leveldb.cpp(185): note: see reference to function template instantiation 'pybind11::object pybind11::detail::object_api<pybind11::handle>::operator ()<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::SequentialFile**&>(const std::string &,leveldb::SequentialFile **&) const' being compiled
./leveldb/leveldb.cpp(185): note: see reference to function template instantiation 'pybind11::object pybind11::detail::object_api<pybind11::handle>::operator ()<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::SequentialFile**&>(const std::string &,leveldb::SequentialFile **&) const' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(1836): error C2665: 'pybind11::detail::type_caster_base<type>::cast': none of the 3 overloads could convert all the argument types
        with
        [
            type=leveldb::RandomAccessFile
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(904): note: could be 'pybind11::handle pybind11::detail::type_caster_base<type>::cast(const leveldb::RandomAccessFile *,pybind11::return_value_policy,pybind11::handle)'
        with
        [
            type=leveldb::RandomAccessFile
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(876): note: or       'pybind11::handle pybind11::detail::type_caster_base<type>::cast(leveldb::RandomAccessFile &&,pybind11::return_value_policy,pybind11::handle)'
        with
        [
            type=leveldb::RandomAccessFile
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(870): note: or       'pybind11::handle pybind11::detail::type_caster_base<type>::cast(const leveldb::RandomAccessFile &,pybind11::return_value_policy,pybind11::handle)'
        with
        [
            type=leveldb::RandomAccessFile
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(1838): note: while trying to match the argument list '(leveldb::RandomAccessFile **, pybind11::return_value_policy, nullptr)'
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2045): note: see reference to function template instantiation 'pybind11::tuple pybind11::make_tuple<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::RandomAccessFile**&>(const std::string &,leveldb::RandomAccessFile **&)' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2199): note: see reference to function template instantiation 'pybind11::detail::simple_collector<pybind11::return_value_policy::automatic_reference>::simple_collector<const std::string&,leveldb::RandomAccessFile**&>(const std::string &,leveldb::RandomAccessFile **&)' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2199): note: see reference to function template instantiation 'pybind11::detail::simple_collector<pybind11::return_value_policy::automatic_reference>::simple_collector<const std::string&,leveldb::RandomAccessFile**&>(const std::string &,leveldb::RandomAccessFile **&)' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2219): note: see reference to function template instantiation 'pybind11::detail::simple_collector<pybind11::return_value_policy::automatic_reference> pybind11::detail::collect_arguments<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::RandomAccessFile**&,void>(const std::string &,leveldb::RandomAccessFile **&)' being compiled
./leveldb/leveldb.cpp(196): note: see reference to function template instantiation 'pybind11::object pybind11::detail::object_api<pybind11::handle>::operator ()<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::RandomAccessFile**&>(const std::string &,leveldb::RandomAccessFile **&) const' being compiled
./leveldb/leveldb.cpp(196): note: see reference to function template instantiation 'pybind11::object pybind11::detail::object_api<pybind11::handle>::operator ()<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::RandomAccessFile**&>(const std::string &,leveldb::RandomAccessFile **&) const' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(1836): error C2665: 'pybind11::detail::type_caster_base<type>::cast': none of the 3 overloads could convert all the argument types
        with
        [
            type=leveldb::WritableFile
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(904): note: could be 'pybind11::handle pybind11::detail::type_caster_base<type>::cast(const leveldb::WritableFile *,pybind11::return_value_policy,pybind11::handle)'
        with
        [
            type=leveldb::WritableFile
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(876): note: or       'pybind11::handle pybind11::detail::type_caster_base<type>::cast(leveldb::WritableFile &&,pybind11::return_value_policy,pybind11::handle)'
        with
        [
            type=leveldb::WritableFile
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(870): note: or       'pybind11::handle pybind11::detail::type_caster_base<type>::cast(const leveldb::WritableFile &,pybind11::return_value_policy,pybind11::handle)'
        with
        [
            type=leveldb::WritableFile
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(1838): note: while trying to match the argument list '(leveldb::WritableFile **, pybind11::return_value_policy, nullptr)'
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2045): note: see reference to function template instantiation 'pybind11::tuple pybind11::make_tuple<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::WritableFile**&>(const std::string &,leveldb::WritableFile **&)' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2199): note: see reference to function template instantiation 'pybind11::detail::simple_collector<pybind11::return_value_policy::automatic_reference>::simple_collector<const std::string&,leveldb::WritableFile**&>(const std::string &,leveldb::WritableFile **&)' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2199): note: see reference to function template instantiation 'pybind11::detail::simple_collector<pybind11::return_value_policy::automatic_reference>::simple_collector<const std::string&,leveldb::WritableFile**&>(const std::string &,leveldb::WritableFile **&)' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2219): note: see reference to function template instantiation 'pybind11::detail::simple_collector<pybind11::return_value_policy::automatic_reference> pybind11::detail::collect_arguments<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::WritableFile**&,void>(const std::string &,leveldb::WritableFile **&)' being compiled
./leveldb/leveldb.cpp(207): note: see reference to function template instantiation 'pybind11::object pybind11::detail::object_api<pybind11::handle>::operator ()<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::WritableFile**&>(const std::string &,leveldb::WritableFile **&) const' being compiled
./leveldb/leveldb.cpp(207): note: see reference to function template instantiation 'pybind11::object pybind11::detail::object_api<pybind11::handle>::operator ()<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::WritableFile**&>(const std::string &,leveldb::WritableFile **&) const' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(1836): error C2665: 'pybind11::detail::type_caster_base<type>::cast': none of the 3 overloads could convert all the argument types
        with
        [
            type=leveldb::FileLock
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(904): note: could be 'pybind11::handle pybind11::detail::type_caster_base<type>::cast(const leveldb::FileLock *,pybind11::return_value_policy,pybind11::handle)'
        with
        [
            type=leveldb::FileLock
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(876): note: or       'pybind11::handle pybind11::detail::type_caster_base<type>::cast(leveldb::FileLock &&,pybind11::return_value_policy,pybind11::handle)'
        with
        [
            type=leveldb::FileLock
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(870): note: or       'pybind11::handle pybind11::detail::type_caster_base<type>::cast(const leveldb::FileLock &,pybind11::return_value_policy,pybind11::handle)'
        with
        [
            type=leveldb::FileLock
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(1838): note: while trying to match the argument list '(leveldb::FileLock **, pybind11::return_value_policy, nullptr)'
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2045): note: see reference to function template instantiation 'pybind11::tuple pybind11::make_tuple<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::FileLock**&>(const std::string &,leveldb::FileLock **&)' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2199): note: see reference to function template instantiation 'pybind11::detail::simple_collector<pybind11::return_value_policy::automatic_reference>::simple_collector<const std::string&,leveldb::FileLock**&>(const std::string &,leveldb::FileLock **&)' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2199): note: see reference to function template instantiation 'pybind11::detail::simple_collector<pybind11::return_value_policy::automatic_reference>::simple_collector<const std::string&,leveldb::FileLock**&>(const std::string &,leveldb::FileLock **&)' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2219): note: see reference to function template instantiation 'pybind11::detail::simple_collector<pybind11::return_value_policy::automatic_reference> pybind11::detail::collect_arguments<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::FileLock**&,void>(const std::string &,leveldb::FileLock **&)' being compiled
./leveldb/leveldb.cpp(305): note: see reference to function template instantiation 'pybind11::object pybind11::detail::object_api<pybind11::handle>::operator ()<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::FileLock**&>(const std::string &,leveldb::FileLock **&) const' being compiled
./leveldb/leveldb.cpp(305): note: see reference to function template instantiation 'pybind11::object pybind11::detail::object_api<pybind11::handle>::operator ()<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::FileLock**&>(const std::string &,leveldb::FileLock **&) const' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(1836): error C2665: 'pybind11::detail::type_caster_base<type>::cast': none of the 3 overloads could convert all the argument types
        with
        [
            type=leveldb::Logger
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(904): note: could be 'pybind11::handle pybind11::detail::type_caster_base<type>::cast(const leveldb::Logger *,pybind11::return_value_policy,pybind11::handle)'
        with
        [
            type=leveldb::Logger
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(876): note: or       'pybind11::handle pybind11::detail::type_caster_base<type>::cast(leveldb::Logger &&,pybind11::return_value_policy,pybind11::handle)'
        with
        [
            type=leveldb::Logger
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(870): note: or       'pybind11::handle pybind11::detail::type_caster_base<type>::cast(const leveldb::Logger &,pybind11::return_value_policy,pybind11::handle)'
        with
        [
            type=leveldb::Logger
        ]
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(1838): note: while trying to match the argument list '(leveldb::Logger **, pybind11::return_value_policy, nullptr)'
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2045): note: see reference to function template instantiation 'pybind11::tuple pybind11::make_tuple<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::Logger**&>(const std::string &,leveldb::Logger **&)' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2199): note: see reference to function template instantiation 'pybind11::detail::simple_collector<pybind11::return_value_policy::automatic_reference>::simple_collector<const std::string&,leveldb::Logger**&>(const std::string &,leveldb::Logger **&)' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2199): note: see reference to function template instantiation 'pybind11::detail::simple_collector<pybind11::return_value_policy::automatic_reference>::simple_collector<const std::string&,leveldb::Logger**&>(const std::string &,leveldb::Logger **&)' being compiled
D:\python-leveldb\third_party\pybind11\include\pybind11\cast.h(2219): note: see reference to function template instantiation 'pybind11::detail::simple_collector<pybind11::return_value_policy::automatic_reference> pybind11::detail::collect_arguments<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::Logger**&,void>(const std::string &,leveldb::Logger **&)' being compiled
./leveldb/leveldb.cpp(350): note: see reference to function template instantiation 'pybind11::object pybind11::detail::object_api<pybind11::handle>::operator ()<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::Logger**&>(const std::string &,leveldb::Logger **&) const' being compiled
./leveldb/leveldb.cpp(350): note: see reference to function template instantiation 'pybind11::object pybind11::detail::object_api<pybind11::handle>::operator ()<pybind11::return_value_policy::automatic_reference,const std::string&,leveldb::Logger**&>(const std::string &,leveldb::Logger **&) const' being compiled

It seems it is erroring due to c++ ** args

@YannickJadoul
Copy link
Collaborator

Yes. pybind11 does not support pointers to pointers to something. What type would you expect that to be on the Python side?

@kumaraditya303
Copy link
Contributor Author

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?

@YannickJadoul
Copy link
Collaborator

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.

@EricCousineau-TRI
Copy link
Collaborator

One minor pain point I've ran into is wrapping calls to PYBIND11_OVERRIDE* macros.

We've worked around in Drake, but it ain't pretty. Example (older fork of pybind11, so you'll need to munge the names):
https://github.com/RobotLocomotion/drake/blob/6ee5e9325821277a62bd5cd5456ccf02ca25dab7/bindings/pydrake/systems/framework_py_systems.cc#L110-L159

@kumaraditya303
Copy link
Contributor Author

kumaraditya303 commented Jan 23, 2021

@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.
Trampoline class is for Env class of https://github.com/google/leveldb/blob/master/include/leveldb/env.h

@YannickJadoul
Copy link
Collaborator

@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 PYBIND11_OVERRIDE_PURE, as @EricCousineau-TRI indicates.

But again, Foo ** cannot be converted to a valid Python type, as ... well, it has properties you can't match with Python object. As an argument, you can't change the object a variable reference, for example, in Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants