C23 auto x C++ auto.

Liste des GroupesRevenir à cl c  
Sujet : C23 auto x C++ auto.
De : thiago.adams (at) *nospam* gmail.com (Thiago Adams)
Groupes : comp.lang.c
Date : 26. May 2024, 15:49:30
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v2vela$3e4pn$1@dont-email.me>
User-Agent : Mozilla Thunderbird
I think most people is not aware of this:
 From 3096 C23 draft
"
6.7.9 Type inference
...
  2 For such a declaration that is the definition of an object the init-    declarator shall have the form
    direct-declarator = assignment-expression
"
Basically "direct-declarator" differs from "declarator" because it does not contains pointer.
Then the type inference using auto and pointer is something undefined in C23.
struct node{
     struct node * next;
};
int main(){
    struct node node = {};
    auto * p = node.next;
}
<source>:7:4: error: 'auto' requires a plain identifier, possibly with attributes, as declarator
     7 |    auto * p = node.next;
       |    ^~~~
This differs from C++.

Date Sujet#  Auteur
26 May 24 * C23 auto x C++ auto.16Thiago Adams
26 May 24 +* Re: C23 auto x C++ auto.11Bonita Montero
26 May 24 i+* Re: C23 auto x C++ auto.8David Brown
26 May 24 ii+- Re: C23 auto x C++ auto.1Bonita Montero
26 May 24 ii+* Re: C23 auto x C++ auto.3Thiago Adams
27 May 24 iii+- Re: C23 auto x C++ auto.1David Brown
7 Jun 24 iii`- Re: C23 auto x C++ auto.1Lawrence D'Oliveiro
27 May 24 ii`* Re: C23 auto x C++ auto.3Blue-Maned_Hawk
27 May 24 ii `* Re: C23 auto x C++ auto.2David Brown
7 Jun 24 ii  `- Re: C23 auto x C++ auto.1Lawrence D'Oliveiro
27 May 24 i`* Re: C23 auto x C++ auto.2Blue-Maned_Hawk
27 May 24 i `- Re: C23 auto x C++ auto.1Bonita Montero
26 May 24 +* Re: C23 auto x C++ auto.3Michael S
26 May 24 i`* Re: C23 auto x C++ auto.2Thiago Adams
26 May 24 i `- Re: C23 auto x C++ auto.1Thiago Adams
27 May 24 `- Different languages (off-topic in CLC) (Was: C23 auto x C++ auto.)1Kenny McCormack

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal