INF: Passing a Stream File Pointer (FILE *) Between DLLs

ID Number: Q50336

5.10 6.00 6.00a

OS/2

Summary:

In Microsoft C versions 5.1, 6.0, and 6.0a, in OS/2, a function cannot

call a function in a DLL that fopen()s a buffered stream file whose

stream pointer (FILE *) is passed as an argument to another DLL. This

procedure cannot be done with LLIBCDLL-created DLLs because the second

DLL has no way to know where the internal C run-time library data

structures are, which in the case below would be the data structures

for the file stream that was opened in the first DLL.

If this procedure is used, a General Protection (GP) Fault occurs when

the function in the second DLL attempts to fread() the stream for the

first time.

To share file streams between DLLs or between an .EXE and DLLs, use

the dynamically linked, multithread support C run-time function

CRTLIB.DLL. The correct way to do this is to have one of your DLLs

export a version of the fread() function and/or fopen() function. The

fopen() and fread() that get called must be in the same DLL.

Additional reference words: 5.10 6.00 6.00a