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

How extern is used?

How extern can be used?

In which file the variable without extern to be declared?

Or there is no such restrictions?

Parents
  • "Extern is used to access global variables/functions that have been declared in another module/file."

    Actually, the global variables/functions must be defined in another module/file - extern provides just a declaration.

    The definition is what actually creates the "object"; ie, allocates memory or generates code.
    Every "object" must have exactly one definition.

    A declaration simply provides information that an "object" is defined elsewhere.
    An "object" may have many declarations.

Reply
  • "Extern is used to access global variables/functions that have been declared in another module/file."

    Actually, the global variables/functions must be defined in another module/file - extern provides just a declaration.

    The definition is what actually creates the "object"; ie, allocates memory or generates code.
    Every "object" must have exactly one definition.

    A declaration simply provides information that an "object" is defined elsewhere.
    An "object" may have many declarations.

Children
No data