Discussion:
error C2894: templates cannot be declared to have 'C' linkage
sumit
2007-03-04 07:42:19 UTC
Permalink
Dear friends
I am using fann for my ocr project (academic) .
I compiled the fann and its examples successfully in VC++6.
But when compiling my own application i am getting error

c:\program files\microsoft visual studio\vc98\include\math.h(514) : error
C2894: templates cannot be declared to have 'C' linkage

Then i tried to compile the xor_train.c after renaming it xor_train.cpp . I
got the same error.

Then i used c++ binding . I tried to compile xor_sample.cpp and i got same
error.

Please suggest a way . It would be nice if u keep it simple as i am not a
hardcore programmer .

Thanking you
--
Sumit
Vincenzo Di Massa
2007-03-04 11:36:08 UTC
Permalink
The problem seems to be that the M$ version of math.h for C++ uses templates.
I guess somewhere (fann, your code) there is a piece of code think this one:

#ifdef __cplusplus
extern "C" {
#endif
...
#include <math.h>
...
#ifdef __cplusplus
}
#endif

Try moving the #include <math.h> outside of the extern "C" thing...
Or better, try to use a C version of math.h.

Regards
Vincenzo
Post by sumit
Dear friends
I am using fann for my ocr project (academic) .
I compiled the fann and its examples successfully in VC++6.
But when compiling my own application i am getting error
c:\program files\microsoft visual studio\vc98\include\math.h(514) : error
C2894: templates cannot be declared to have 'C' linkage
Then i tried to compile the xor_train.c after renaming it xor_train.cpp .
I got the same error.
Then i used c++ binding . I tried to compile xor_sample.cpp and i got same
error.
Please suggest a way . It would be nice if u keep it simple as i am not a
hardcore programmer .
Thanking you
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Continue reading on narkive:
Loading...