Fehler in der Deklaration Source Code
-
Hi,
habe folgendes kleines Problem.
//..Deklaration..// int (__cdecl * ScopeSetAmpScale) (int ScopeHandle, int BeamNum, double AmpScale); ... ScopeSetAmpScale = (int (__cdecl * )(int, struct tagTArrDbl *))GetProcAddress(DllInst, "ScopeSetAmpScale"); if (ScopeSetAmpScale == NULL) { FreeLibrary(DllInst); MessageBox("Error DLL loading 9","Error",MB_ICONSTOP); exit(-1); }Mein Kompiler meldet als Fehler
error C2440: '=': 'int (__cdecl *)(int,tagTArrDbl *)' kann nicht in 'int (__cdecl *)(int,int,double)' konvertiert werden
Diese Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder FunktionsformatIch habe aber alles nach Herstellerangaben deklariert. Leider weiß ich nicht mehr weiter. Vielleicht kann einer von euch den Fehler in der Deklaration sehen.
//..Deklaration.. int (__cdecl * ScopeShowNext) (int Prm, struct tagTArrDbl *PrmD ); ... ScopeShowNext = (int (__cdecl * )(int, struct tagTArrDbl *))GetProcAddress(DllInst, "ShowNext"); if (ScopeShowNext == NULL) { FreeLibrary(DllInst); MessageBox("Error DLL loading 3","Error",MB_ICONSTOP); exit(-1); }Diese Deklaration klappt ohne Probleme und soll laut Hersteller genau gleich sein.
Versuche damit ein externes Oszilloskop anzusteuern
-
Der cast in der ersten Version stimmt nicht.
Besser so//..Deklaration..// int (__cdecl * ScopeSetAmpScale) (int ScopeHandle, int BeamNum, double AmpScale); ... ScopeSetAmpScale = (int (__cdecl * )(int, int, double))GetProcAddress(DllInst, "ScopeSetAmpScale"); if (ScopeSetAmpScale == NULL) { FreeLibrary(DllInst); MessageBox("Error DLL loading 9","Error",MB_ICONSTOP); exit(-1); }
-
Super, danke!
-
Übersichtlicher und weniger fehleranfällig wäre ein typedef...
typedef int (__cdecl * Func) (int ScopeHandle, int BeamNum, double AmpScale); Func ScopeSetAmpScale; ScopeSetAmpScale = (Func)GetProcAddress(DllInst, "ScopeSetAmpScale");