{"record":{"id":"a774b12aed1b3b15","repo":"deepinsight/insightface","slug":"unknown-calling-convention-for-function","errorCode":null,"errorMessage":"Unknown calling convention '{}' for function '{}'","messagePattern":"Unknown calling convention '(.+?)' for function '(.+?)'","errorType":"exception","errorClass":"LookupError","httpStatus":null,"severity":"error","filePath":"cpp-package/inspireface/python/inspireface/modules/core/native.py","lineNumber":600,"sourceCode":"    Subclasses load libraries for specific platforms.\n    \"\"\"\n\n    # library names formatted specifically for platforms\n    name_formats = [\"%s\"]\n\n    class Lookup:\n        \"\"\"Looking up calling conventions for a platform\"\"\"\n\n        mode = ctypes.DEFAULT_MODE\n\n        def __init__(self, path):\n            super(LibraryLoader.Lookup, self).__init__()\n            self.access = dict(cdecl=ctypes.CDLL(path, self.mode))\n\n        def get(self, name, calling_convention=\"cdecl\"):\n            \"\"\"Return the given name according to the selected calling convention\"\"\"\n            if calling_convention not in self.access:\n                raise LookupError(\n                    \"Unknown calling convention '{}' for function '{}'\".format(\n                        calling_convention, name\n                    )\n                )\n            return getattr(self.access[calling_convention], name)\n\n        def has(self, name, calling_convention=\"cdecl\"):\n            \"\"\"Return True if this given calling convention finds the given 'name'\"\"\"\n            if calling_convention not in self.access:\n                return False\n            return hasattr(self.access[calling_convention], name)\n\n        def __getattr__(self, name):\n            return getattr(self.access[\"cdecl\"], name)\n\n    def __init__(self):\n        self.other_dirs = []\n","sourceCodeStart":582,"sourceCodeEnd":618,"githubUrl":"https://github.com/deepinsight/insightface/blob/7fadd420c2351d0ffa8cac403421c1a3ed733365/cpp-package/inspireface/python/inspireface/modules/core/native.py#L582-L618","documentation":"Thrown by LibraryLoader.Lookup.get() when the requested ctypes calling convention key is not present in the loader's access dict. The loader is constructed with cdecl only (ctypes.CDLL), so asking for any other convention (e.g. 'stdcall') raises this LookupError before the symbol is fetched.","triggerScenarios":"Calling loader.get(func_name, calling_convention='stdcall') or any convention other than 'cdecl' on the InspireFace library loader. Only happens in custom/low-level code that drives the ctypes loader directly rather than through the wrapped API functions.","commonSituations":"Porting Windows-era ctypes code that used WinDLL/stdcall; copy-pasting a generic ctypes loader snippet with a convention parameter; library version changes that removed non-cdecl loaders.","solutions":["Use the default: call get(name) or pass calling_convention='cdecl'","If you truly need stdcall on Windows, construct the loader with a stdcall entry (ctypes.WinDLL) so the key exists in access","Update your loader snippet to the current InspireFace API which is cdecl-only"],"exampleFix":"# before\nfunc = loader.get('HFCreateInspireFaceSession', 'stdcall')\n# after\nfunc = loader.get('HFCreateInspireFaceSession', 'cdecl')\n# or simply the default\nfunc = loader.get('HFCreateInspireFaceSession')","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def valid_convention(c: str) -> bool:\n    return c == 'cdecl'","tryCatchPattern":"try:\n    fn = loader.get(name, cc)\nexcept LookupError:\n    fn = loader.get(name)  # fall back to cdecl","preventionTips":["Never pass calling_convention unless you extended the loader yourself","Keep custom ctypes code aligned with the cdecl-only constructor"],"tags":["ctypes","calling-convention","native-library"],"backgroundTag":"invalid-calling-convention","analyzedSha":"7fadd420c2351d0ffa8cac403421c1a3ed733365","analyzedAt":"2026-08-28T15:44:01.850Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}