can some pro quickly explain what's the use of extern keyword?
sometimes i see a function declared as:
extern int myFunc();
what does the extern do there?
Printable View
can some pro quickly explain what's the use of extern keyword?
sometimes i see a function declared as:
extern int myFunc();
what does the extern do there?
It is redundant and not necessary (for function prototypes, as in your case).
The only reason you would be using extern is if you were using global variables across modules. And global variables, as most people agree, are a bad thing, so if you see the word "extern" you should probably be thinking "bad code," or at least code that could be improved.
EDIT: Of course, there is the extern "C" thing, but that's just the extern keyword hacked into a new role. If you aren't calling C code from C++ code, there is no need for it.