Liste des Groupes | Revenir à cl c |
On 13/12/2024 01:59, James Kuyper wrote:...On 12/1/24 06:34, David Brown wrote:
>"int", "void" and "double" are totally different types in my view.>
"int", "pointer to int", "array of int", "function returning int" all
have a relation that means I would not describe them as /totally/
different types - though I would obviously still call them /different/
types.
>
The syntax of C allows one declaration statement to declare multiple
identifiers of types related in this way - it does not allow declaration
of types of /totally/ different types.
There's a rule I sometimes find useful, when trying to choose a precise
definition for a poorly defined term: figure out what statements you'd
like to say using the term, then define it in such a way as to guarantee
that those statements are correct.
>
In C, a declaration may contain an init-declarator-list, preceded by
declaration-specifiers and optionally by an attribute-specifer-sequence
(6.7p1). Each of the declarators in the list share the
declaration-specifiers and the attribute-specifier-sequence (6.7p7). Any
syntax that's part of a declarator applies to that declarator's
identifier.
>
Therefore, your statement suggests that two types should be considered
"totally different types" if they are incompatible in either the
declaration-specifiers or the attribute-specifier-sequence. With that
definition, 6.7p7 in the standard would guarantee the truth of your
statement above.
>
Does that definition sound suitable?
That definition sounds correct, yes, but also completely useless. It
leads directly to a tautology - you can declare two things in the same
declaration in C if you are allowed to declare them in the same
declaration in C.
Les messages affichés proviennent d'usenet.