It looks very similar to scope, so I really don’t understand the difference. What makes storage classes different from each other? How is auto not the same as static, extern or register?

  • pancake@lemmygrad.ml
    link
    fedilink
    arrow-up
    1
    ·
    4 hours ago

    From what I recall, register is ignored by modern compilers (it used to mean that you wanted the variable stored inside CPU registers, but nowadays compilers are smarter and know when to do that). Meanwhile, static is basically a global variable that has the scope of a local variable, while extern is a global variable that you want to explicitly tell the compiler it’s defined in a different compilation unit.