Subject: Re: Problems with gdb under NetBSD 1.0
To: Bakul Shah <email@example.com>
From: Mark P. Gooderum <firstname.lastname@example.org>
Date: 12/13/1994 23:49:00
> This is a major problem. The usual way out is to create a
> declaration of your own but then it conflicts with a
> declaration of the same thing in a vendor provided include
> file. I consider writing your own prototype to be
> equivalent to casting the whole damn call! Alas, it is not
> always possible to avoid it.
> Someone ought write a book on porting software and how to
> write portable software.
Several people have...after building a very system dependant product
on a 1/2 dozen very different Unixes I'm a huge fan of autoconf.
Autoconf basically generates a set of portability defines. There are
many default tests provided, as well as several basic types of tests
added. The defines that autoconf generates are automatically generated
on a given system. In our case of lseek() one might have a get of
autoconf tests that generate the following defines:
LSEEEK_IN_OSFCNS_H /* SunOS 4 lossage */
Autoconf would have simple standard compile tests for most of these defines,
the 3rd define might be generated by a run time test.
The referencing code would then reference lseek by saying:
# ifdef NEED_LSEEK_PROTOTYPE
LSEEK_OFFSET_ARG_TYPE lseek(int fd, LSEEK_OFFSET_ARG_TYPE off, int whence);
# ifdef LSEEK_IN_UNISTD_H
# include <unistd.h>
# else if defined(LSEEK_IN_OSFCNS_H)
# include <osfcns.h>
# define x(y /* puke and die, more portable than #error */
/* deal with it, define lseek(), whatever */
It's really less work than you would think. The above can be isolated in
a port.h header or whatever. The big winnage is that after you've done
2-3 ports the rest start to go lots quicker since autoconf does the
tests automatically. That also means that things like:
don't break when something changes in the following OS release.