1

What's the significance of auto keyword from the programmer's perspective ? Its a default storage class for automatic variables which are allocated on stack and get deleted as their scope ends. So when this is the default behaviour what's the point of keeping this extra "not so significant" keyword ?

I recently started reading the "Expert C programming - Deep C secrets" where Peter Van Der Linden mentions that "auto keyword is apparently useless" but is meaningful for compiler writers in some way. What's that ? Can someone justify the existence of this keyword ?

8
  • 1
    Because it's useless, its meaning has been changed in C++11. More information about the old storage class here
    – phuclv
    Jun 11, 2014 at 16:15
  • A good explanation is provided [here][1]. [1]: stackoverflow.com/questions/1046477/…
    – unxnut
    Jun 11, 2014 at 16:16
  • @unxnut If you're going to post a link to another QA on SO that answers the question, flag as a duplicate.
    – aruisdante
    Jun 11, 2014 at 16:18
  • 1
    Does is carry same meaning in C11 as well ? And before someone mark it as duplicate the point of this question is to know in what way it was useful for the compiler designer(as specified in book) yet being redundant for the programmer? Jun 11, 2014 at 16:20
  • 2
    as I said, its meaning was changed in C11, and both the old and new meaning has been discussed in the link above. The reason was answered in this link: "This keyword is actually a leftover from C's predecessor B, where there were no base types: everything was int, pointer to int, array of int.(*) Declarations would be either auto or extrn [sic]. C inherited the "everything is int" as a default rule, so you could declare integers with"
    – phuclv
    Jun 12, 2014 at 4:22

0

Browse other questions tagged or ask your own question.