3 ms·
"auto" in c is a storage class specifier, like "register", "extern" or "static". https://en.cppreference.com/w/c/language/storage_duration https://en.cpprefere
by 1ris 6y ago
"auto" in c is a storage class specifier, like "register", "extern" or "static".
https://en.cppreference.com/w/c/language/storage_duration https://en.cppreference.com/w/c/language/storage_duration
It was considered pretty useless by most, so c++11 recycled the keyword to mean something different.
- jwilk 6y agoSee also: https://www.seebs.net/faqs/c-iaq.html#question-1.8 https://www.seebs.net/faqs/c-iaq.html#question-1.8
- mywittyname 6y agoAuto is the implicit default right? As in function scoped, stack allocated, and lives until the function is returned? K&R (Second Ed). Makes no mention of the auto keyword in Section 1.10, but it does say, > Each local variable in a function comes into existence only when the function is called, and disappears when the function is exited. This is why such variables are usually known as automatic [sic] variables[...]
- 1ris 6y agoyes, exactly. That's why there is no need for it in modern c. This compiler however is different: The type is optional (and assumed to be int). Say you have a variable declaration "auto int i;". Back then you could omit int, now you can omit auto.