Search code examples
cfunctionextern

Are functions external by default?


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.