On Feb 9, 2:08 pm, George <Geo...@discussions.microsoft.com> wrote:
Thanks Drew!
Compiler/Linker will error if linkage specifications don't match.
What is your context about the one-sentence statement? You mean you pref=
- Show quoted text -
extern "C" specifies external linkage spec for the functions that you
declare somewhere. If these functions are just used in one compilation
unit, giving in extern "C" or not probably does not matter. It is only
when you use those functions somewhere else (in some other .cpp/.c
file). Usually, you would not copy the full implementation of that
function everywhere. You would have a header file and you keep
including that in the other compilation units. And you would include
that header (with function declarations) in the file that implements
them. So, the compiler is able to see that the function has already
been declared as extern "C", and hence you don't need to put it with
the function definitions. There can be special cases, for example -
the one mentioned by Ben Voigt above regarding putting extern "C" to
dll exported functions.
.. that is there can be cases where you don't have a function