Subject: nested extern declarations considered evil?
To: None <>
From: Christos Zoulas <>
List: tech-userlevel
Date: 12/10/2000 01:18:38
I think it is a good idea to try to clean up our source tree from
'scoped extern' declarations because they lead to unpredictable
problems (see example below). In the past I thought that scoped
extern declarations are cleaner, but I've changed my mind.

In addition we seem to have a lot of duplicated declarations of
functions in our include files that may lead to problems. A quick
look finds:

	sys_siglist, ftruncate, truncate, lseek, psignal, cuserid

Finally the scoped extern declarations in the inline functions in
signal.h are problematic (including errno.h before signal.h produces
different code than including errno.h after signal.h)

Do you think that it is worth it to add:

    -Wmissing-declarations -Wredundant-decls -Wnested-externs

to CFLAGS and cleanup the source tree? XFree86 has done so for their
4.0 tree.

I propose to add
int declare();

around the functions to avoid breakage.


% cat zap1.c
void zap() {
% cat zap2.c
int zap;
% cat main.c
void foo() {
	extern int zap;
void bar() {
	extern void zap();
void main() {
% cc zap1.c zap2.c main.c
% ./a.out
Segmentation fault (core dumped)