Linux vs. libio
Jamie Lokier
jamie.lokier@cern.ch
Mon Dec 20 09:18:00 GMT 1999
Per Bothner wrote:
> Jeffrey A Law <law@cygnus.com> writes:
>
> > While I believe it was an unbelievably dumb thing for the glibc folks to
> > tie libio into the C library,
>
> In other words, you don't think it is a reasonable goal to allow C
> stdio FILEs to be shared with C++ iostream streambufs?
The down side is it's not at all portable, so code that's written on
Linux will output differently on other platforms.
> The best way to synchronize (say) stdout with cout seems to be for
> them both to use the same buffer. The requires (at least if you want
> efficiency) for them to use compatible data structures,
Only the /very/ few fields that are used by inline input/output
functions need to be shared. Since they are simple data fields, sharing
those would be very easy even with many different kinds of C++ ABI.
Everything else, including vtable format and placement does not need to
be shared. Just have the C library call functions (not virtual ones)
like "flush_my_output_stream" etc., and those functions would contain
the vtable lookup code. Or alternatively, have an explicit /C/ vtable
as one of the shared fields and keep it that way for the C++ version.
C++ streams don't have to call that vtable; they merely have to provide
it.
-- Jamie
More information about the Libc-alpha
mailing list