
File loading functions stored inside a DLL
I programmed some functions for loading meshes, textures, etc. and stored them inside a DLL. All of my functions uses a prototype similar to this one (DECLSPEC is defined automatically to either __declspec(dllimport) or __declspec(dllexport)):
extern DECLSPEC TEX* TEX_loadTGA(FILE* texfp);
Strangely enough, the fact that I passes a FILE pointer instead of a filename crash the program when a function such as fread() is called. If I modify the prototype to look like...
extern DECLSPEC TEX* TEX_loadTGA(STRING filename);
...and uses fopen() INSIDE the function, everything works perfectly. Unfortunatly, the design of my engine needs function to access data from a previously opened FILE pointer.
I also tried to make test functions reading data from structs and they all worked perfectly. It seems there are some incompatibility using FILE pointers as parameters and then trying to read trough them with Visual C++ 6.0. Or maybe I did something wrong and in that case, I''d really like to know what.

whenever you''re calling crt functions on the same data (stdio i/o funtions on file pointers, in your case) from exe and dll or from mutiple dlls, you must use the dll version of the c runtime. change that in project settings, c++, code generation. the reason is that right now you have two c runtimes in the same app, and one of them knows nothing of the other, thus crashes when you''re sharing data between them.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement