Please consider the following code:
Test2.h:
#ifndef ABCD
#define ABCD
#ifdef __cplusplus
extern "C" {
#endif
void Foo();
#ifdef __cplusplus
}
#endif
#endif // ABCD
Test2.cpp
#include "StdAfx.h"
#include "Test2.h"
inline void Foo()
{
}
Test.cpp:
#include "stdafx.h"
#include "Test2.h"
int _tmain(int argc, _TCHAR* argv[])
{
Foo();
return 0;
}
When I compile this code I get LNK2019 error (Unresolved external symbol _Foo). I can solve it in two ways.
- Remove the inline keyword.
- Add extern to the function declaration.
Assuming I want this function inline, why do I have to add extern to the declaration?
I use VS2008.
Thanks.