471,853 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,853 software developers and data experts.

ifstream / filebug / FILE*

Hi,

I am tryig to convert part of a c++ IO library. Right now I am removing
all 'FILE*' and replace them with ifstream.

But I have a problem, after seeking through a stream I have to call the
ijg (jpeg library). Since this is a C library it uses FILE*. My question
is then is there a compatibility layer for ifstream <-> FILE* ?
It should work on non-GNU compiler.

Thanks,
Mathieu
Ps: All I found was:
http://gcc.gnu.org/onlinedocs/libstd...__filebuf.html
Jul 22 '05 #1
2 2024
"Mathieu Malaterre" <ma***@free.fr> wrote in message news:ciAKc.49088
I am tryig to convert part of a c++ IO library. Right now I am removing
all 'FILE*' and replace them with ifstream.

But I have a problem, after seeking through a stream I have to call the
ijg (jpeg library). Since this is a C library it uses FILE*. My question
is then is there a compatibility layer for ifstream <-> FILE* ?
It should work on non-GNU compiler.


I don't think there is a portable way to convert an fstream info a FILE. In
practice, I imagine the std::filebuf class contains within it a priviate
member FILE *, but it's not required by the standard nor is the a public
function to get it.
Jul 22 '05 #2
On Sun, 18 Jul 2004 19:35:36 GMT, Mathieu Malaterre <ma***@free.fr> wrote:
Hi,

I am tryig to convert part of a c++ IO library. Right now I am removing
all 'FILE*' and replace them with ifstream.

But I have a problem, after seeking through a stream I have to call the
ijg (jpeg library). Since this is a C library it uses FILE*. My question
is then is there a compatibility layer for ifstream <-> FILE* ?
It should work on non-GNU compiler.

Thanks,
Mathieu
Ps: All I found was:
http://gcc.gnu.org/onlinedocs/libstd...__filebuf.html


There is no standard way to convert ifstream to FILE*.

The only way to get the compatibility you want is to write your own stream
classes. These classes would extend the iostream library but also use a
FILE* internally which you can then make accessible.

Extending the iostream library is not too difficult and is a useful
technique to learn. You could find the technique explained in The
C++ Standard Library by Josuttis for instance.

john

Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Dave Johnston | last post: by
6 posts views Thread by Herv? LEBAIL | last post: by
6 posts views Thread by Ram Laxman | last post: by
4 posts views Thread by hall | last post: by
10 posts views Thread by sam | last post: by
1 post views Thread by Xiaozhou.Yin | last post: by
2 posts views Thread by mpalomas | last post: by
11 posts views Thread by adramolek | last post: by
NeoPa
reply views Thread by NeoPa | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.