I've been trying for days to get my script to compile using a simple string, but but simply refuses to. I've run it by several veteran coders, and referenced it against many websites, but everyone said it looks like it should compile. Any help is greatly appreciated.
Forgot two things
1) I'm aware I have the mystring line commented, I forgot to uncomment it before posting
2) the errors I get are
error: "syntax error before 'namespace'"
warning: "type defaults to 'int' declaration of 'std'"
warning: "data definition has no type or storage class"
occasionally, it refuses to recognize that <string> exists
I'm using cygwin to compile, Dev-C++ to code, and the most recent stable build of the toolchain.
notice the %s ...that means that the argument would correspond
to a string and that printf should print that argument into a string
and not an integer (%d) which you had above ...also all these
are not needed
Nope, that's not the problem. The code was an except from a MUCH larger program, that's why I have all the libs on the makefile. The problem is that it doesn't recognize "using". Tried recompiling both my program AND the toolchain, but no luck.
Also make sure your file has a .CPP extension, otherwise I'm fairly sure it'll try and compile it using a C compiler (Which doesn't have the 'using' keyword nor templates). Either way, make sure MAKE is executing vs-psp-g++ instead of vs-psp-gcc.
If this was meant to be c++ then make sure your file is named something.cpp so that it is compiled by g++ and not gcc (you will see in the compile output which one was used)
string mystring = "text";
SetupCallbacks();
printf("Display some text %s",mystring.c_str());
and change
#include <string.h>
to
#include <string>
(NOTE: I assume you want to use c++ strings, and not c char* type strings)
Danzel.
ps. one other small thing fixing what dot_blank said:
string mystring[] = "test";
that should be
char mystring[] = "test";
if you are using c and not c++ strings, in this case keep #include <string.h>
After spending four days rearranging code, and recompiling...you're telling me my problem was the file extension?
[puts on n00b cap, draws a circle on the chalk board and put nose in it]
I was using main.c, and I'm kicking myself, since I had changed the extension to .cpp earlier, but changed it back before I attempted to implement strings since I had realized I wasn't doing anything at that point that required .cpp.
That would also explain why it would recognize <string.h>, but never <string>. Awesome, thanks everyone.
haha this is by far the most interesting thread
just for the fact to show that the user should first
realize that this forum is for psp DEV ...keyword is DEV
meaning that you would obviously have to know what
DEV is and how to DEV ....and big oops in my enjoyment
of this thread i over saw the mystring.c_str() :)