[Python-Dev] Pep 353: Py_ssize_t advice
David Hopwood
david.nospam.hopwood at blueyonder.co.uk
Sat Sep 23 22:00:29 CEST 2006
Martin v. Löwis wrote:
> David Abrahams schrieb:
>
>>(C++ allows restating of typedefs; if C allows it, that should be
>>something like):
>
> C also allows this; [...]
This is nitpicking, since you agreed the change to the PEP, but are you
sure that C allows this?
From C99 + TC1 + TC2 (http://www.open-std.org/JTC1/SC22/WG14/www/standards):
# 6.2.2 Linkages of identifiers
#
# 6 The following identifiers have no linkage: an identifier declared
# to be anything other than an object or a function; [...]
(i.e. typedef identifiers have no linkage)
# 6.7 Declarations
#
# Constraints
# 3 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.
# 6.7.2.3 Tags
#
# Constraints
# 1 A specific type shall have its content defined at most once.
(There is nothing else in 6.7.2.3 that applies to typedefs.)
Since 6.7 (3) and 6.7.2.3 (1) are constraints, I read this as saying that
a C99 implementation must produce a diagnostic if a typedef is redeclared
in the same scope. If the program is run despite the diagnostic, its behaviour
is undefined.
Several C compilers I've used in the past have needed the idempotence guard
on typedefs, in any case.
--
David Hopwood <david.nospam.hopwood at blueyonder.co.uk>
More information about the Python-Dev
mailing list