i am trying to declare function returning string in header file because i will call this from objective-c. basically this would work, isn't it?
std::string myFunction();
but it throws error message says "Expected ';' after top level declarator", searched a lot, everyones suggest put #include in header files, i tried that as well however it is not working, this time it throws another error message "'string' file not found".
have another function returns double and have no problem with it.
double doSomething(double a);
-
#include <string>
does not work it is throwing error message saying "'string' file not found" . have tried to create new project just in case mine could be damaged but it is not working should i put something in search paths etc?
at last i made it. The solution: have changed "Compile Source As" settings to Objective-C++ under Build Settings / Apple LLVM Compiler 4.2 and it worked like a charm.
#include
? – Joseph Mansfield Apr 7 '13 at 15:17<string>
then either you are not using a C++-compiler (e.g. gcc can behave like a pure C compiler depending on its arguments), or you have a faulty installation or misconfigured your IDE. Look for the filestring
manually on your machine (it has no filename suffix), and check the include file path configured in your IDE. – Arne Mertz Apr 7 '13 at 15:26