Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Today, 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


C still has it around with the same meaning.


There 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?


There are no types in B, only words. Auto denotes storage.


Yes, for example, in old C the type was implicitly int unless mentioned. "Long" means long int" ;)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: