Liste des Groupes | Revenir à cl c |
On 12/1/24 06:34, David Brown wrote: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. I was simply trying to give such "things" can't have /totally/ different types, but need types that are in a certain way related. I didn't go into the details of how they had to be related, because it should have been obvious that those details are precisely what the C standard says in the section about declarations.On 30/11/2024 00:44, Keith Thompson wrote:...There's a rule I sometimes find useful, when trying to choose a preciseDavid apparently has a different definition of "totally different types">
than you do. Since the standard doesn't define that phrase, I suggest
not wasting time arguing about it.
>
"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.
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?
Les messages affichés proviennent d'usenet.