Accessing a routine in a program FROM a dll (circular library reference?)

Accessing a routine in a program FROM a dll (circular library reference?)

I have the following situation:RoutineA and RoutineB are compiled in a static library (Lib1)RoutineC is compiled in a dynamic linked library (Dll1)Lib1 is linked to an executable EXE. At runtime I load Dll1 into the executable and RoutineA calls RoutineC (I learned how to do this from a forum entry onhttp://www.xeffort.com).This all works great, the problem is that I would like RoutineC to call RoutineB in the original library. Right now the only way I can get this to work is by passing a reference to RoutineB into RoutineC: e.g:subroutine RoutineA ... call RoutineB(... , RoutineC) ...ensubroutineIs there a way to do this without passing the reference?I have Composer XE 2011 and use windows, linux, and mac versions. Thanks guys!Nate

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Look in the IVF reference guide under "proceedure pointers".
In routine C (the dll)
add a collection of proceedure pointers (uninitialized (=>NULL))
add an init function that is passed the pointer(s) and copies pointer(s) into appropriate proceedure pointer

Once this is done the dll can use the proceedure pointer for calling the proper function.

Also, in place of default initilaization to =>NULL you could point to a function that gracefull informs the user that the init was not called

Jim Dempsey

www.quickthreadprogramming.com

I don't think we support the F2008 feature of having a function for default initialization of a procedure pointer.

Steve - Intel Developer Support

Thank you Jim and Steve! I haven't implemented this yet but it looks like just what I need. Since the initialization will be done right after the dll is loaded and can be initiated by LIB1 then as the programmer of LIB1 (clients will write their own DLL1's)I can put in the appropriate error checking there and unload the dll if the initialization fails preventing further problems.Nate

I use DLLEXPORT to export routines from my exe file. Then dll libraries used by this exe file can use these routines (in the same way as exe file uses exported routines from dll). It works well.

Leave a Comment

Please sign in to add a comment. Not a member? Join today