So I have this sdk and here is the documentation which is in c++ which so I installed cppyy but when I include the header file with cppyy in python it raises error
// MysticLight_SDK.h : header file
//
#pragma once
typedef int (*LPMLAPI_Initialize)();
typedef int (*LPMLAPI_GetDeviceInfo)(SAFEARRAY** pDevType, SAFEARRAY** pLedCount);
typedef int (*LPMLAPI_GetDeviceName)(BSTR type, SAFEARRAY** pDevName);
typedef int (*LPMLAPI_GetDeviceNameEx)(BSTR type, DWORD index, BSTR* pDevName);
typedef int (*LPMLAPI_GetErrorMessage)(int ErrorCode, BSTR* pDesc);
typedef int (*LPMLAPI_GetLedName)(BSTR type, SAFEARRAY** pLedName);
typedef int (*LPMLAPI_GetLedInfo)(BSTR type, DWORD index, BSTR* pName, SAFEARRAY** pLedStyles);
typedef int (*LPMLAPI_GetLedColor)(BSTR type, DWORD index, DWORD* R, DWORD* G, DWORD* B);
typedef int (*LPMLAPI_GetLedStyle)(BSTR type, DWORD index, BSTR* style);
typedef int (*LPMLAPI_GetLedMaxBright)(BSTR type, DWORD index, DWORD* maxLevel);
typedef int (*LPMLAPI_GetLedBright)(BSTR type, DWORD index, DWORD* currentLevel);
typedef int (*LPMLAPI_GetLedMaxSpeed)(BSTR type, DWORD index, DWORD* maxLevel);
typedef int (*LPMLAPI_GetLedSpeed)(BSTR type, DWORD index, DWORD* currentLevel);
typedef int (*LPMLAPI_SetLedColor)(BSTR type, DWORD index, DWORD R, DWORD G, DWORD B);
typedef int (*LPMLAPI_SetLedColors)(BSTR type, DWORD AreaIndex, SAFEARRAY** pLedName, DWORD* R, DWORD* G, DWORD* B);
typedef int (*LPMLAPI_SetLedColorEx)(BSTR type, DWORD AreaIndex, BSTR pLedName, DWORD R, DWORD G, DWORD B, DWORD );
typedef int (*LPMLAPI_SetLedColorSync)(BSTR type, DWORD AreaIndex, BSTR pLedName, DWORD R, DWORD G, DWORD B, DWORD );
typedef int (*LPMLAPI_SetLedStyle)(BSTR type, DWORD index, BSTR style);
typedef int (*LPMLAPI_SetLedBright)(BSTR type, DWORD index, DWORD level);
typedef int (*LPMLAPI_SetLedSpeed)(BSTR type, DWORD index, DWORD level);
the errors
Traceback (most recent call last):
File ".\check.py", line 5, in <module>
cppyy.include('MysticLight_SDK.h')
File "C:\Users\sarfaraz\AppData\Local\Programs\Python\Python37\lib\site-packages\cppyy\__init__.py", line 217, in include
raise ImportError('Failed to load header file "%s"%s' % (header, err.err))
ImportError: Failed to load header file "MysticLight_SDK.h"
In file included from input_line_18:1:
./MysticLight_SDK.h:7:38: error: unknown type name 'SAFEARRAY'
typedef int (*LPMLAPI_GetDeviceInfo)(SAFEARRAY** pDevType, SAFEARRAY** pLedCount);
^
./MysticLight_SDK.h:7:60: error: unknown type name 'SAFEARRAY'
typedef int (*LPMLAPI_GetDeviceInfo)(SAFEARRAY** pDevType, SAFEARRAY** pLedCount);
^
./MysticLight_SDK.h:8:38: error: unknown type name 'BSTR'
typedef int (*LPMLAPI_GetDeviceName)(BSTR type, SAFEARRAY** pDevName);
^
./MysticLight_SDK.h:8:49: error: unknown type name 'SAFEARRAY'
typedef int (*LPMLAPI_GetDeviceName)(BSTR type, SAFEARRAY** pDevName);
^
./MysticLight_SDK.h:9:40: error: unknown type name 'BSTR'
typedef int (*LPMLAPI_GetDeviceNameEx)(BSTR type, DWORD index, BSTR* pDevName);
^
./MysticLight_SDK.h:9:64: error: unknown type name 'BSTR'
typedef int (*LPMLAPI_GetDeviceNameEx)(BSTR type, DWORD index, BSTR* pDevName);
^
./MysticLight_SDK.h:10:55: error: unknown type name 'BSTR'
typedef int (*LPMLAPI_GetErrorMessage)(int ErrorCode, BSTR* pDesc);
^
./MysticLight_SDK.h:11:35: error: unknown type name 'BSTR'
typedef int (*LPMLAPI_GetLedName)(BSTR type, SAFEARRAY** pLedName);
^
./MysticLight_SDK.h:11:46: error: unknown type name 'SAFEARRAY'
typedef int (*LPMLAPI_GetLedName)(BSTR type, SAFEARRAY** pLedName);
^
./MysticLight_SDK.h:12:35: error: unknown type name 'BSTR'
typedef int (*LPMLAPI_GetLedInfo)(BSTR type, DWORD index, BSTR* pName, SAFEARRAY** pLedStyles);
^
./MysticLight_SDK.h:12:59: error: unknown type name 'BSTR'
typedef int (*LPMLAPI_GetLedInfo)(BSTR type, DWORD index, BSTR* pName, SAFEARRAY** pLedStyles);
^
./MysticLight_SDK.h:12:72: error: unknown type name 'SAFEARRAY'
typedef int (*LPMLAPI_GetLedInfo)(BSTR type, DWORD index, BSTR* pName, SAFEARRAY** pLedStyles);
^
./MysticLight_SDK.h:13:36: error: unknown type name 'BSTR'
typedef int (*LPMLAPI_GetLedColor)(BSTR type, DWORD index, DWORD* R, DWORD* G, DWORD* B);
^
./MysticLight_SDK.h:14:36: error: unknown type name 'BSTR'
typedef int (*LPMLAPI_GetLedStyle)(BSTR type, DWORD index, BSTR* style);
^
./MysticLight_SDK.h:14:60: error: unknown type name 'BSTR'
typedef int (*LPMLAPI_GetLedStyle)(BSTR type, DWORD index, BSTR* style);
^
./MysticLight_SDK.h:15:40: error: unknown type name 'BSTR'
typedef int (*LPMLAPI_GetLedMaxBright)(BSTR type, DWORD index, DWORD* maxLevel);
^
./MysticLight_SDK.h:16:37: error: unknown type name 'BSTR'
typedef int (*LPMLAPI_GetLedBright)(BSTR type, DWORD index, DWORD* currentLevel);
^
./MysticLight_SDK.h:17:39: error: unknown type name 'BSTR'
typedef int (*LPMLAPI_GetLedMaxSpeed)(BSTR type, DWORD index, DWORD* maxLevel);
^
./MysticLight_SDK.h:18:36: error: unknown type name 'BSTR'
typedef int (*LPMLAPI_GetLedSpeed)(BSTR type, DWORD index, DWORD* currentLevel);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
cppyy works fine I tested it without the headers and there were no error
to code to check the implementation of this
import cppyy
cppyy.include('MysticLight_SDK.h')
cppyy.cppdef("""
int main() {
int c;
int a = 10;
int b = 10;
c = a+b;
return c;
};""")
c = cppyy.gbl.main
print(c())
Thanks in advance
Looks like
SAFEARRAY
lives inoaidl.h
, which would need to be included beforeMysticLight_SDK.h
(and any other headers that are normally be included when usingMysticLight_SDK.h
from C++).cppyy pulls in the standard C++ headers in the form of a precompiled header, but any other platform and project headers need to be explicitly included, or need to be packaged into a separate dictionary (https://cppyy.readthedocs.io/en/latest/utilities.html#dictionaries) to allow automatic loading.
To be more precise, using the .zip file that you link above, the following:
works for me.
Beyond that, I don't know what would be the use case, because that
MysticLight_SDK.h
header only contains typedefs of function pointers, no actual APIs.