I was confused whether to use extern for forward declarations of functions in C. The scenario is each function is in separate .c/.cpp file. I understood from going through this question - External linkage of const in C , that if all are .c files I should not use extern for forward declaration irrespective of whether the function is defined in same file or not.
But I would like to know more about this when to explicitly use extern for forward declarations (I think when the function being forward declared is defined in a different language than calling one, extern would be required), and any caveats to be aware of.
In C language there's such thing as extern inline
which has a special meaning and in which an explicit extern
makes a difference.
Other than that, there's never any point in specifying an explicit extern
in functon declarations, since functions in C and C++ always have external linkage by defualt.
The matter of "different language" is probably about such things as extern "C"
, but that's a completely different contruct from plain extern
.