Hu********@gmail.com kirjutas:
#define ABC_DLL_F_GET(hDll, func_name)
\ {
\
(fproc_t &)lpfn##func_name = abc_GetProcAddress(hDll,
#func_name); \
}
If I want to modity this #define macro to something in good C++ style
like a inline func, how should I do
If your goal is not to repeat the function name, then the best I can
imagine is something like (warning - untested code!):
std::map<std::string, fproc_tfunc;
void ImportAbcFunc(HDllType hDll, const char* func_name) {
func[func_name] = abc_GetProcAddress(hDll, func_name);
}
ImportAbcFunc(hDll, "foo");
ImportAbcFunc(hDll, "bar");
int result = (*func["foo"])(arg1, arg2);
This works better if all functions have the same signature.
Anyway, I see nothing awfully wrong with the macro as well here.
Preprocessor is part of C++ after all.
hth
Paavo