A question about tenative definitions

Paul de Bra debra at wsinfo11.info.win.tue.nl
Tue Mar 5 02:10:18 AEST 1991


In article <4218 at lupine.NCD.COM> rfg at lupine.ncd.com (Ron Guilmette) writes:
>I'm having a discussion with a C implementor I know about the meaning of
>the following sentence from the ANSI C standard...
>[ description of tentative definition deleted ]
>What exactly does this mean?  My off-the-cuff interpretation of this
>statement was that if you had two files like:
>... [ example deleted ]
>and if you compiled them both and then tried to link them together into
>the same single program, that you should get an error at link time because
>there are two conflicting external *definitions* of the variable xxyyzz.

Nope, you are wrong.
int xxyyzz; int xxyyzz; int xxyyzz;
may be repeated as often as you like, as they are "tentative" definitions.
you may have several (non-conflicting) tentative definitions of the same
variable.
A true (non-tentative) definition is one with initialization.
you may write int xxyyzz=1; only once.
if none of the (tentative) definitions has an initializer then the
variable will be initialized with 0.

Paul.
(debra at win.tue.nl, debra at research.att.com)



More information about the Comp.std.c mailing list