Subject: Private declarations (Was: Is there a new tcsh source)
To: None <>
From: Henrys Elche <>
List: current-users
Date: 10/10/1994 17:56:36
> > I just grab stuff off the net, and 70% of the time it works without
> > any changes [...].  25% of the time I have to fix a few problems:
> > they generally fall into one of two categories:
> [...]
> > - People have their own prototypes for system calls or library
> >   variables (one common example of this is sys_errlist[]).  This is
> >   just bad programming; deleting the offending prototypes solves this
> >   problem.
> As someone who writes such "private" declarations, I'd like to note
> that it's _not_ "just bad programming".  In my case, at least, it's
> simply that there is no header file I can count on to declare such
> things for me, so it's either use them undeclared (which works in only
> a few instances) or declare them myself.  On at least some of the
> machines I work with, there is no header file at all that declares
> these things.  (Or I could litter my source with conditionals, I
> suppose.)
> Take sys_errlist, for example.  On my NeXT at home, it's in <errno.h>,
> but on the Suns at work, there is no include file (at least not under
> /usr/include) that declares it.  Or take alarm(), for another example.
> At home, that's in <libc.h>, which doesn't exist at work; at work, it's
> in <unistd.h> or <sys/unistd.h>, neither of which exists at home.
> Or does your definition of "bad programming" include declaring things
> myself because I can't find an include file that declares them
> everywhere I need to have the code build?

The problem is not the private declaration, but the way things are
declared. Most time people use something like

extern char *sys_errlist[];

which is wrong, because it is in scope for every OS. The next step
some people do is to use

#include <errno.h>
#ifndef __goody_os__
extern char *sys_errlist[];

which is also bad, because it could be also wrong for another OS.

May be a portable solution is something like

(in "projectname_errno.h", 'projectname' should be the name of your project)
#include "projectname_config.h"

#ifdef HAS_ERRNO_H
#  include <errno.h>

extern const char *const sys_errlist[];


(in "projectname_config.h")
#if defined(__NetBSD__) || defined(__another_nice_os__)
#  define HAS_ERRNO_H

#if defined(__bad_os__) || defined(__next:-)_bad_os__)


GNU autoconfigure could help here. A standard would help much better.
Posix and ANSI C don't help. Are they standard(s...) ? ;-)

I'm sure you use a portable solution, but I (we?) have seen to much
garbage. :-(

>                                       der Mouse

der freche Elch ==:-)

#define wheel(diameter) wood(diameter)
#ifdef linux
#  define Wheel(again) wheel(again)
#  define wood(again) Wheel(again)
#endif /* oops ==:-,) */

--                 []  (Internet)

Elche sind auch nur Tiere ==:-)