Discussion:
Can we pass FILE * across library
(too old to reply)
Sachin
2009-09-22 10:23:01 UTC
Permalink
In my application i want to share a log file pointer between my main program
and a dynamically loaded library .What i am doing is opening the file using
fopen in the main program and passing FILE* to one of the exported function .
It works fine for XP and vista but surprisingly on Windows 2003 Server R2 it
hangs in the exported function of dll.
If i remove references to FILE* it works ..

Any idea what could be reason and what is good idea to share LOG file across
libraries

Thanks
Sachin
Martin T.
2009-09-22 10:34:51 UTC
Permalink
Post by Sachin
In my application i want to share a log file pointer between my main program
and a dynamically loaded library .What i am doing is opening the file using
fopen in the main program and passing FILE* to one of the exported function .
It works fine for XP and vista but surprisingly on Windows 2003 Server R2 it
hangs in the exported function of dll.
If i remove references to FILE* it works ..
Any idea what could be reason and what is good idea to share LOG file across
libraries
As far as I know sharing a FILE* between different runtime library
versions is not supported, just as it's not supported to share memory
allocation. (i.e. you can't free() what a different rtl allocated)
Do you build the DLL against the same runtime library or a different one?

br,
Martin
Sachin
2009-09-22 11:36:02 UTC
Permalink
yes they were poiting to different CRT libraries.
I recompiled the DLL with /MD flag and embed manifest set to to false
Its working fine now ..

Thanks
Post by Martin T.
Post by Sachin
In my application i want to share a log file pointer between my main program
and a dynamically loaded library .What i am doing is opening the file using
fopen in the main program and passing FILE* to one of the exported function .
It works fine for XP and vista but surprisingly on Windows 2003 Server R2 it
hangs in the exported function of dll.
If i remove references to FILE* it works ..
Any idea what could be reason and what is good idea to share LOG file across
libraries
As far as I know sharing a FILE* between different runtime library
versions is not supported, just as it's not supported to share memory
allocation. (i.e. you can't free() what a different rtl allocated)
Do you build the DLL against the same runtime library or a different one?
br,
Martin
Continue reading on narkive:
Loading...