🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4179

Re: Tentative definitions

#4179
From: Clive D.W. Feather
Date: Wed, 04 Oct 1995 21:35
28 lines
1735 bytes
In article <DFv3rK.3wv@ukpsshp1.serigate.philips.nl>,
Stephen Baynes <baynes@ukpsshp1.serigate.philips.nl> wrote:
> Clive D.W. Feather (clive@stdc.demon.co.uk) wrote:
>: static int var_a = 1;      /* Internal linkage, definition */
>: static int var_a;          /* Remains internal linkage */
>: extern int var_a;          /* Remains internal linkage */
>: int var_a;                 /* Error - var_a has internal linkage */
> Just to clarify that I understand this. With particular reference to the last
> two lines of the example, adding "extern" means you are not worried about
> something being external and leaving "extern" out means that you want it 
> external. A bit counter intuitive!

Actually, adding extern means that this is not a definition but only a
declaration of something in another translation unit.

> Can anyone give the rationale for these rules? Or for why tentative
> definitions where introduced?

Tentative definitions allow you to have

    int i;

in several places in the same source file and get a definition.

-- 
Clive D.W. Feather                       | If you lie to the compiler,
clive@demon.net        (work, preferred) | it will get its revenge.
clive@stdc.demon.co.uk (home)            |   - Henry Spencer
Technical Details
Message-ID: <DFy1Bp.Dou@stdc.demon.co.uk>
Path: arc1-ca.pugleaf.net!stdc.demon.co.uk!clive
References: <44pdr1$378@news.tuwien.ac.at> <DFuxK4.62z@stdc.demon.co.uk> <DFv3rK.3wv@ukpsshp1.serigate.philips.nl>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!stdc.demon.co.uk!clive
From: clive@stdc.demon.co.uk (Clive D.W. Feather)
Newsgroups: comp.std.c
Subject: Re: Tentative definitions
Date: Wed, 4 Oct 1995 21:35:48 GMT
Organization: Demon Internet Limited (personal account)
Message-ID: <DFy1Bp.Dou@stdc.demon.co.uk>
References: <44pdr1$378@news.tuwien.ac.at> <DFuxK4.62z@stdc.demon.co.uk> <DFv3rK.3wv@ukpsshp1.serigate.philips.nl>
Reply-To: clive@demon.net
X-NNTP-Posting-Host: stdc.demon.co.uk