3 ms·
On auto. Couldn't they just define auto as _Auto and then add a header like <stdauto.h> which does #define auto _Auto like they did with _Bool in C99?
by ainar-g 11y ago
On auto. Couldn't they just define auto as
_Auto
and then add a header like <stdauto.h> which does
#define auto _Auto
like they did with _Bool in C99?
- jcranmer 11y agoauto is already a keyword in C11, a type of storage specifier (like static or register).
- PeCaN 11y agoYes, that's exactly why they'd use _Auto and a header to redefine the keyword. Existing code that does auto x = 3; (implicit int type) wouldn't break, but #include <stdauto.h> auto x = 4.2f; would be the new meaning.
- _kst_ 11y agoExisting code that does "auto x = 3;" is already broken; the "implicit int" rule was removed in C99. But "auto int x = 3;" is valid (and the "auto" keyword is useless in that context).
- jwilk 11y agoFrom <http://www.seebs.net/faqs/c-iaq.html#section-1 http://www.seebs.net/faqs/c-iaq.html#section-1>: 1.8: What's the auto keyword good for? Declaring vehicles.
- PeCaN 11y agoThis is inherited from early Lisp implementations, where it was common to define a struct car { ... }; which would get cumbersome to type.