declaration (no memory allocation)
definition (memory allocated)
int foo(int a, int b); /* declare, by default compiler prepends extern to such declarations */
int foo(int a, int b) {
/* defined*/
}
int foo(int a, int b); = extern int foo(int a, int b)
int bar; /* declare and define; mem allocated */
extern int bar; /* declare; mem not allocated */
extern int bar = 0; /* declare and intialized; hence, mem allocated */
cf: One Definition Rule in C, C++
extern "C" is a linkage specification.
No comments:
Post a Comment