[comp.std.c] extern question

karzes@mfci.UUCP (Tom Karzes) (07/04/88)

In article <8200@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>What you should have written was
>
>	static int foo();
>
>Aesthetics and proper use of the language have no necessary connection.

I've always found K&R to be very obscure on external declarations.  Among
other things, they don't explicitly say that static can be used for forward
function declarations, although pcc-based C compilers have always allowed
it, and it makes sense.

However, I still consider static forwards to be broken in C.  Sure, they
work for functions, but what about data?  For example, consider the
following:

        struct foo {
            int         a;
            struct bar *bar_ptr;
        };

        struct bar {
            int         b;
            struct foo *foo_ptr;
        };

        extern struct foo   x;
        extern struct bar   y;

        struct foo  x = {123, &y};
        struct bar  y = {456, &x};


Now suppose you want to make x and y static.  What do you do?  You still
need a forward declaration for at least one of them in order to refer to
it in an initialization list.  Unless there's some way to do this that I
don't know about, it's a glaring hole in C.  Even if this case didn't
matter, it would still be nice to be able to issue forward declarations
for static data.  Does anyone know if this has been fixed in ANSI C
(e.g., by allowing something suitably gross like "extern static" as a
forward declaration)?