1 // This program tests out how the various objects can be loaded
2 // dynamically and method calls made on them.
6 #include "ace/Log_Msg.h"
9 typedef Magazine
* (*Magazine_Creator
) ();
12 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
14 ACE_UNUSED_ARG (argc
);
15 ACE_UNUSED_ARG (argv
);
19 int retval
= dll
.open (ACE_DLL_PREFIX
ACE_TEXT("DLL_Today"));
22 ACE_ERROR_RETURN ((LM_ERROR
,
28 // Cast the void* to non-pointer type first - it's not legal to
29 // cast a pointer-to-object directly to a pointer-to-function.
30 void *void_ptr
= dll
.symbol (ACE_TEXT ("create_magazine"));
31 ptrdiff_t tmp
= reinterpret_cast<ptrdiff_t> (void_ptr
);
32 mc
= reinterpret_cast<Magazine_Creator
> (tmp
);
36 ACE_ERROR_RETURN ((LM_ERROR
,
43 std::unique_ptr
<Magazine
> magazine (mc ());
50 // The other library is now loaded on demand.
52 retval
= dll
.open (ACE_DLL_PREFIX
ACE_TEXT ("DLL_Newsweek"));
56 ACE_ERROR_RETURN ((LM_ERROR
,
62 // Cast the void* to non-pointer type first - it's not legal to
63 // cast a pointer-to-object directly to a pointer-to-function.
64 void_ptr
= dll
.symbol (ACE_TEXT ("create_magazine"));
65 tmp
= reinterpret_cast<ptrdiff_t> (void_ptr
);
66 mc
= reinterpret_cast<Magazine_Creator
> (tmp
);
70 ACE_ERROR_RETURN ((LM_ERROR
,
77 std::unique_ptr
<Magazine
> magazine (mc ());