3 ms·
The keyword was always there, but it meant something different. In modern C++, it tells the compiler to perform type inference. In B, it told the compiler to dy
by Hemospectrum 5y ago
The keyword was always there, but it meant something different. In modern C++, it tells the compiler to perform type inference. In B, it told the compiler to dynamically allocate a variable on the stack, as opposed to assigning it a static address, or a register.
- flukus 5y agoThere does seem to be some type inference going on though "auto a; a= 'hi!';", or maybe it's just defaulting to an int/pointer type? If it is type inference it would have been awful to have the variable declaration at the top but the type declaration strewn through the function. So it looks as though C switched from default static to default auto? I wonder if the programmers of the time sneered at the waste this added?
- obviouslynotme 5y agoThere are no types in B, only words. Auto denotes storage.
- wbkang 5y agoYes, for example, in old C the type was implicitly int unless mentioned. "Long" means long int" ;)
- saagarjha 5y agoC still has it around with the same meaning.
- IncRnd 5y agoToday, auto in C is still a storage class that denotes stack allocation of a variable. This is related to the other storage classes of register, static, and extern. In C each variable and function has two attributes, type and storage class