The C23 standard apparently has introduced using "auto" keyword for auto type deduction, see here, just like in C++11. However, there seems to be some differences.
According to here, https://en.cppreference.com/w/cpp/keyword/auto, after C++11, auto
is no longer a storage duration specifier in C++.
However, I cannot easily find an equivalently statement for C23. Is it the case that auto
is still a storage class specifier in C in C23?
Can we still write int auto x = 1;
in C23?
EDIT: The answer to the first question is yes. But as pointed out by Andrew Henle in comments below, the second question is different:
Can we still write float auto x = 1;
in C23?
As quoted by @AndrewHenle and @VladfromMoscow, in the standard document, 6.7.1 Storage-class specifiers, paragraph 4
auto shall only appear in the declaration specifiers of an identifier with file scope or along with other storage class specifiers if the type is to be inferred from an initializer.
It seems that this does not cover the case float auto x = 1;
, if this declaration is not in file scope.
What's the interpretation of this?
There is another question: the sentence seems confusing because we surely can use auto without "other storage specifiers", couldn't we? Like auto a = 1;
.