Reputation: 11
In my Visual studio 2012 ,C++11 static function I have:
kuku* kuku::createKuku(bool enable, std::string dumpPat)
{
#ifndef ANDROID
#include "kukuWin.h"
return new kukuWin(enable, dumpPat);
#else
#include "kukuAndroid.h"
return new kukuAndroid(enable, dumpPat);
#endif
}
in c++98 it works , but here I have multiple errors:
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\excpt.h(29): error : linkage specification is not allowed
1> extern "C" {
1> ^
1>
1>C:\Program Files (x86)\Windows Kits\8.0\Include\shared\windef.h(17): error : linkage specification is not allowed
1> extern "C" {
1> ^
1>
1>C:\Program Files (x86)\Windows Kits\8.0\Include\shared\specstrings.h(49): error : linkage specification is not allowed
1> extern "C" {
1> ^
1>
1>C:\Program Files (x86)\Windows Kits\8.0\Include\shared\driverspecs.h(133): error : linkage specification is not allowed
1> extern "C" {
1> ^
1>
1>C:\Program Files (x86)\Windows Kits\8.0\Include\shared\minwindef.h(42): error : linkage specification is not allowed
1> extern "C" {
1> ^
:)
Can anyone help me with it,
Thanks
Upvotes: 0
Views: 1098
Reputation: 41513
An #include
directive will put the full text of the included file exactly where the directive is. So all that stuff in "kukuWin.h" is going smack dab in the middle of your createKuku
function, where it doesn't belong.
You'll almost always put inclusions at the top of your source files.
Upvotes: 3