J
jacob navia
Document: WG14/N1360
Date: 2009/02/27
References: WG14/N1321, WG14/N1336, WG14/N1346
Authors: Jim Thomas
Reply to: Jim Thomas <[email protected]>
Subject: benign typedef redefinition
C++ allows a typedef redefinition with the same name as a previous
typedef to appear in the same scope, as long as it names the same type.
Some C compilers allow similar typedef redefinition as an extension,
though C99 does not allow it. Adding benign typedef redefinition to C1x
would enhance consistency with C++, standardize some existing practice,
and safely eliminate a constraint that is unhelpful and an occasional
nuisance to users.
Recommended change (to C1x draft N1336): Change 6.7 #3 from:
If an identifier has no linkage, there shall be no more than one
declaration of the identifier (in a declarator or type specifier) with
the same scope and in the same name space, except for tags as specified
in 6.7.2.3.
to:
If an identifier has no linkage, there shall be no more than one
declaration of the identifier (in a declarator or type specifier) with
the same scope and in the same name space, except a typedef specifier
can be used to redefine the name of any type declared in that scope to
refer to the type to which it already refers, and except for tags as
specified in 6.7.2.3.
--------------------------------------------------------------------
This is exactly the behavior of lcc-win. If a typedef is repeated,
and it names the same type, lcc-win will silently accept this.
This comes mostly from data types that are defined in several headers
and you need to include both of them.
I think this is a good idea.
Date: 2009/02/27
References: WG14/N1321, WG14/N1336, WG14/N1346
Authors: Jim Thomas
Reply to: Jim Thomas <[email protected]>
Subject: benign typedef redefinition
C++ allows a typedef redefinition with the same name as a previous
typedef to appear in the same scope, as long as it names the same type.
Some C compilers allow similar typedef redefinition as an extension,
though C99 does not allow it. Adding benign typedef redefinition to C1x
would enhance consistency with C++, standardize some existing practice,
and safely eliminate a constraint that is unhelpful and an occasional
nuisance to users.
Recommended change (to C1x draft N1336): Change 6.7 #3 from:
If an identifier has no linkage, there shall be no more than one
declaration of the identifier (in a declarator or type specifier) with
the same scope and in the same name space, except for tags as specified
in 6.7.2.3.
to:
If an identifier has no linkage, there shall be no more than one
declaration of the identifier (in a declarator or type specifier) with
the same scope and in the same name space, except a typedef specifier
can be used to redefine the name of any type declared in that scope to
refer to the type to which it already refers, and except for tags as
specified in 6.7.2.3.
--------------------------------------------------------------------
This is exactly the behavior of lcc-win. If a typedef is repeated,
and it names the same type, lcc-win will silently accept this.
This comes mostly from data types that are defined in several headers
and you need to include both of them.
I think this is a good idea.