You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am new to cppyy, not sure if this is an issue or simply I didn't get the right way to use it.
It seems that if a function is declared as extern "C" then it is not accessible from cppyy.
Here is a quick way to test it:
$ cat test.h
namespace test {
extern "C" int test_extern_c(void);
int test_normal(void);
}
$ python3
Python 3.10.0+ (heads/v3.10-dirty:099a94fba3, Nov 5 2021, 13:02:25) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cppyy
>>> cppyy.include("test.h")
True
>>> cppyy.gbl.test.test_normal
<cppyy.CPPOverload object at 0x7f1dfb343340>
>>> cppyy.gbl.test.test_extern_c
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: <namespace cppyy.gbl.test at 0x561e5d770300> has no attribute 'test_extern_c'. Full details:
type object 'test' has no attribute 'test_extern_c'
'test::test_extern_c' is not a known C++ class
'test_extern_c' is not a known C++ template
'test_extern_c' is not a known C++ enum
>>>
>>> cppyy.gbl.test_extern_c
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: <namespace cppyy.gbl at 0x561e5bf3e580> has no attribute 'test_extern_c'. Full details:
type object '' has no attribute 'test_extern_c'
'test_extern_c' is not a known C++ class
'test_extern_c' is not a known C++ template
'test_extern_c' is not a known C++ enum
>>>
Did I miss anything?
Thanks a lot.
The text was updated successfully, but these errors were encountered:
Applying the above, if used from source, requires both rebuilding cppyy-cling and cppyy-backend, which is a bit of a hassle, but I can't think of a workaround, other than providing a manual helper/wrapper. (Which should probably be fine if there are no more than a handful of these functions.)
@wlav Thanks for confirming this. Yes, right now I just pick up the definition from header files and using cppdef to define it again and it works perfectly fine.
I am new to cppyy, not sure if this is an issue or simply I didn't get the right way to use it.
It seems that if a function is declared as extern "C" then it is not accessible from cppyy.
Here is a quick way to test it:
Did I miss anything?
Thanks a lot.
The text was updated successfully, but these errors were encountered: