Advertisement
Hello, all ...
I need to interface a library that expects to communicate through a FILE * to my code written using ofstream. In these endeavors, I would like to just have my ofstream return a FILE * that this library can use, but I don't see how I can do that. The ofstream.rdbuf() returns a basic_filebuf, but there seems to be no way of getting a FILE * from it in a cross platform way (this code has to work on Mac OSX, using gcc, as well as Windows, using the MSVC.NET compiler).
Am I doomed to a C-style interface to my lower level file objects, just because this library expects a FILE *? I'm sure i'm not the only one who has run into this ...
Regards,
John
Falling You - exploring the beauty of voice and sound
www.fallingyou.com
Advertisement
Advertisement
-
Re: FILE * from std::ofstream?
Wed, June 14, 2006 - 9:53 PMFILE is a straight C type for OS-specific file info. It is defined in stdio.h.
see msdn.microsoft.com/library/...wchar.asp
for an example of using fopen() to obtain a pointer to the FILE info. I dont know much more about it though... good luck! -
-
Re: FILE * from std::ofstream?
Wed, June 14, 2006 - 10:00 PM
Jason,
Alas, I decided to just expose a more abstract interface to the code calling me, and I found a way to get around the (kinda nasty) FILE *. The iostream stuff just seems safer, anyway ...
Regards,
John
Falling You - exploring the beauty of voice and sound
www.fallingyou.com
-
-
Re: FILE * from std::ofstream?
Wed, June 14, 2006 - 10:55 PMGood to hear John :) Sounds like you made a better design decision in the end :)
-
-