[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] global variables in tcc
From: |
Lluís Batlle i Rossell |
Subject: |
Re: [Tinycc-devel] global variables in tcc |
Date: |
Mon, 1 Apr 2013 21:27:22 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Mon, Apr 01, 2013 at 08:58:06PM +0200, Daniel Glöckner wrote:
> Hi,
>
> On Mon, Apr 01, 2013 at 04:55:18PM +0200, Lluís Batlle i Rossell wrote:
> > > GCC and Clang allow these to be merged together at link-time, which
> > > means users who make mistakes such as missing `extern' in header files
> > > still get the multiple definitions merged.
> > >
> > > tcc is stricter and perhaps more conformant in disallowing this.
> >
> > I think that the C standard requires the gcc and clang behaviour, 'extern'
> > never being a required word.
> >
> > No?
>
> I just took a look inside the N1570 C11 draft.
> Chapter 6.9 paragraph 5 says:
>
> "If an identifier declared with external linkage is used in an expression
> ([...]), somewhere in the entire program there shall be exactly one external
> definition for the identifier; otherwise, there shall be no more than one."
>From K&R:
"An external declaration for an object is a definition if it has an initializer.
An external object declaration that does not have an initializer, and does not
contain the extern specifier, is a tentative definition. If a definition for an
object appears in a translation unit, any tentative definitions are treated
merely as redundant declarations. If no definition for the object appears in the
translation unit, all its tentative definitions become a single definition with
initializer 0."
I don't know if this is a fight between K&R and the C11 draft. :)
Regards,
Lluís.
- [Tinycc-devel] global variables in tcc, Lluís Batlle i Rossell, 2013/04/01
- Re: [Tinycc-devel] global variables in tcc, Rob, 2013/04/01
- Re: [Tinycc-devel] global variables in tcc, Lluís Batlle i Rossell, 2013/04/01
- Re: [Tinycc-devel] global variables in tcc, Daniel Glöckner, 2013/04/01
- Re: [Tinycc-devel] global variables in tcc,
Lluís Batlle i Rossell <=
- Re: [Tinycc-devel] global variables in tcc, Rob, 2013/04/01
- Re: [Tinycc-devel] global variables in tcc, Lluís Batlle i Rossell, 2013/04/02
- Re: [Tinycc-devel] global variables in tcc, Rob, 2013/04/02
- Re: [Tinycc-devel] global variables in tcc, grischka, 2013/04/02
- Re: [Tinycc-devel] global variables in tcc, Lluís Batlle i Rossell, 2013/04/02
- Re: [Tinycc-devel] global variables in tcc, Rob, 2013/04/04