Re: Suggestion: 'porting issues' web page
Date: Sat, 5 Jun 1999 02:00:06 +0200
From: Marcus Brinkmann <Marcus.Brinkmann@ruhr-uni-bochum.de>
> libc doesn't have FILE->_IO_read_ptr but that FILE->__bufp-FILE->__buffer
> can be used instead, or the libtool madness (although this will evidently
> be fixed soon)..
The fromer yes, the latter no, because it is just a bug.
I think a warning is appropriate here. Pretending you know the
internals of FILE is bad programming practice. It is inherently
non-portable and may even break when you upgrade libc. Therefore,
when porting programs to the Hurd, it is better to avoid using the
members of FILE if you can. Marcus, please add such a warning to your
porting pages if possible.
If you really have to use the members of FILE anyway, keep in mind
that the Hurd will eventually switch to use libio (which has
FILE->_IO_read_ptr) instead of GNU stdio. If libio is in use, the
symbol _STDIO_USES_IOSTREAM is defined by <stdio.h>. This means you
can use
#ifdef _STDIO_USES_IOSTREAM
/* libio specific code. */
#else
/* GNU stdio specific code. */
#endif
If, after my warning, you still want to use the members of FILE in
your own programs, please add a comment in your program:
/* Yes I know that I'm not supposed to use the members of FILE, but
I really need this ugly hack here.
However, do not try this at home! */
This way you don't set a bad example that people will follow blindly.
Thanks,
Mark
Reply to: