Boost logo

Boost :

From: Edward Diener (eddielee_at_[hidden])
Date: 2005-02-24 20:09:32

Jonathan Turkanis wrote:
> Edward Diener wrote:
>> Gennadiy Rozental wrote:
>>> 3. init_unit_test_suite
>>> I need to call external function from inside of DLLs. How it should
>>> be declared? Cause I am getting unresolved symbols error
>> Most Windows compilers support __declspec(dllexport) or
>> __declspec(dllimport) in front of a function or class name and it is
>> used like:
>> #if defined(BUILD_MY_DLL)
>> #define MY_DLL_IMPORT_EXPORT_MACRO __declspec(dllexport)
>> #elif defined(USE_MY_DLL)
>> #define MY_DLL_IMPORT_EXPORT_MACRO __declspec(dllimport)
>> #else
>> #define MY_DLL_IMPORT_EXPORT_MACRO __declspec(dllimport)
>> #endif
>> and then for some function or class you want to export/import you
>> write:
>> MY_DLL_IMPORT_EXPORT_MACRO void SomeFunction();
> I think Gennadiy wants the dll code to call a user-defined function,
> and the problem is that if you declare the function and then leave it
> undefined the linker complains, even though this works fine with
> static linking, since the user supplies the definition and the linker
> sees everything at once.

OK, but would it not be better just to use boost::function<> to allow the
user to pass in a user-defined function at run-time from wherever he chooses
? This is much more flexible than attempting to declare a user-defined
function in a Dll which the end-user is supposed to define and depend on
compile/link to resolve it..

Boost list run by bdawes at, gregod at, cpdaniel at, john at