[SOLVED] Are functions external by default?

Issue

Is a function without a storage class specified in its declaration and definition :

void func(void); // declaration

void func(void) { // implementation
    
}

be equivalent to the function with extern storage class in its declaration and definition? :

extern void func(void); // declaration

extern void func(void) { // implementation
    
}

Solution

From the C Standard (6.2.2 Linkages of identifiers)

5 If the declaration of an identifier for a function has no
storage-class specifier, its linkage is determined exactly as if it
were declared with the storage-class specifier extern. If the
declaration of an identifier for an object has file scope and no
storage-class specifier, its linkage is external.

Answered By – Vlad from Moscow

Answer Checked By – Cary Denson (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *