Python: accessing DLL function using ctypes — access by function *name* fails

前端 未结 3 789
不思量自难忘°
不思量自难忘° 2021-01-12 04:11

myPythonClient (below) wants to invoke a ringBell function (loaded from a DLL using ctypes). However, attempting to access ring

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-12 04:56

    Your C++ compiler is mangling the names of all externally visible objects to reflect (as well as their underlying names) their namespaces, classes, and signatures (that's how overloading becomes possible).

    In order to avoid this mangling, you need an extern "C" on externally visible names that you want to be visible from non-C++ code (and therefore such names cannot be overloaded, nor in C++ standard can they be inline, within namespaces, or within classes, though some C++ compilers extend the standard in some of these directions).

提交回复
热议问题