I recently started trying to program some psp stuff and I'm having trouble with a few things. Most importantly is dynamicly sized arrays. What I normaly do in C++ is something like this:
int size = 10;
char test[];
test = new char[size];
I know you can't do that in C code which is what the samples seem to be writen in. If I rename the file with .cpp it looks like it uses psp-g++ but I learned C++ using Visual Studio 6.0 so I'm not used to make files and such. It gives me an error saying that there is no size defined for test. I actually haven't programmed in C++ for a while, so maybe I'm just doing it wrong all together. Can I just not do somthing like that or is there a C equivilant?
should work. "size" needs to be pretty small, because it gets allocated on the stack, and implicitly freed when the function returns (ie, its like any other local). If you want to allocate it on the heap, use
int size = 10;
char *test1 = new char[size];
I'm using the kprintf example from the samples, I just rename it to main.cpp and add the above lines to the main function. Do I need to change the make file at all for C++?
Edit: It compiles fine as C if I use malloc(). I'd much rather get the C++ way working, but this works for now. Thanks for the help :)
The reason for this is you are using gcc to link, you need to add -lstdc++ to your libraries in order to use C++. As you are using the pspsdk makefiles then in your apps makefile add the line LIBS=-lstdc++ and it _should_ work ;)