c++builder - c++-builder: convert into stdcall type -
i'm trying port old owl-c++-builder-projekt use xe2 , owlnext. in old file, call line
(farproc)lp_i2copen = getprocaddress(hi_i2c, "i2copen");
while lp_i2open defined with
#ifdef win32 #define calling_convention __stdcall #else #define calling_convention far pascal #endif int calling_convention (*lp_i2copen)(hwnd hndl,hinstance hinstance, struct i2c_prop far *ps); #ifdef _win64 typedef int_ptr (far winapi *farproc)(); #else typedef int (far winapi *farproc)(); #endif winbaseapi farproc winapi getprocaddress(...
those code-blocks multiple files. thought order intuitive.
now have difficulties rewrite needed. understand, left side understood converting-method giving value back, can't assigned specific value, "l-value expected"-error thrown. however, don't quite know how convert farproc fit lp_i2copen... trying without convertions throws error:
[bcc32 fehler] dio.cpp(2906): e2034 konvertierung von 'int (__stdcall *)()' nach 'int (__stdcall *)(hwnd__ *,hinstance__ *,i2c_prop *)' nicht möglich
so, know mistakes i'm doing line?
(farproc)lp_i2copen = getprocaddress(hi_i2c, "i2copen");
regards, julian
casting l-values invalid, , afaik has been invalid, although compilers accepted it. technically, create temporary of type farproc gets assigned result of getprocaddress() before being discarded. correct way looks this:
// function type alias typedef int callingconvention i2copenfn(hwnd, hinstance, i2c_prop*); // read , convert function pointer i2copenfn* lp_i2copen = (i2copenfn*)getprocaddress(hi_i2c, "i2copen");
note things "far" obsolete. note c-style cast ugly, don't have type safety anyway , it's isolated restricted amount of code. if can though, use proper linking instead of loading dll @ runtime.
Comments
Post a Comment