This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

static == extern ?

extern data and static diffenece

since static is used for keeping the value after existing function, extern use the value in other module.

are they the same?

Parents
  • "I do agree that a variable can be global without being used extern, but why the heck would anyone do that?"

    In 'C', everything defined at file scope is automatically "Public" - whether or not any other module actually references it.
    You use 'static' with file-scope objects if you want to prevent them from being "Public"

Reply
  • "I do agree that a variable can be global without being used extern, but why the heck would anyone do that?"

    In 'C', everything defined at file scope is automatically "Public" - whether or not any other module actually references it.
    You use 'static' with file-scope objects if you want to prevent them from being "Public"

Children
No data