0

I am trying to port some code using the Dev_C++ 4.9.9.2 compiler and I cannot get it to recognise the standard algorithm template as in

#ifdef __cplusplus
extern "C" {
#endif

#include <algorithm>
#include <string>
using namespace std;

Whenever I attempt to compile I get numerous error messages, the majority saying "template with C linkage." What am I doing wrong? Is there some setting I need to adjust on the compiler.

Tech Specs - I am running the compiler on Windows XP SP3 on Oracle VirtualBox, which in turn is on a Ubuntu 10.10 AMD64 host machine.

2
  • what is the original code language? C? you might need to put the #endif at the end maybe....been a while since I have looked at C++. Also, you don't have another curly brace....
    – TheChes44
    Jul 18, 2011 at 20:33
  • Minor point: the #include <algorithm> will fail if it's not a C++ environment anyway. As a result, there is little point in using #ifdef __cplusplus guards around the extern "C" {
    – Sjoerd
    Jul 18, 2011 at 20:45

1 Answer 1

1

The answer seems to have been given in an answer that has now been deleted: move the includes outside the extern "C" { braces

using namespace std ;
#include <algorithm>
#include <string>

#ifdef __cplusplus
extern "C" {
#endif

This compiles without error messages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.