With the latest version of the pspgl, i cant seem to manage to compile the code in c++. All i did was rename the simple.c and psp-setup.c to *.cpp, I also modified the Makefile to use psp-g++, rather then psp-gcc. and added USE_PSPSDK_LIBC = 1. Even when trying to use this in any other project, i still get an error. With the previous build this method worked.
C++ has stricter type requirements than C. Check the types you're passing to pspDebugInstallErrorHandler(), I bet you're converting one of them to (void*) and you shouldn't.
Paco wrote:C++ has stricter type requirements than C. Check the types you're passing to pspDebugInstallErrorHandler(), I bet you're converting one of them to (void*) and you shouldn't.
i'm not sure what i am passing it in, i didnt even touch the code, but renamed it to a cpp file and added extern "C" and changed ti to psp-g++
The thing that is different then the previous build is that now there is a psp-setup.c file.
There are 10 types of people in the world: Those who understand binary, and those who don't...
Thanhda wrote:i didnt even touch the code, but renamed it to a cpp file
That's what I'm saying, C++ has stricter type requirements than C in many cases, and thus some C code that relies on relaxed type checks will not compile if treated as C++.
Thanhda wrote:i didnt even touch the code, but renamed it to a cpp file
That's what I'm saying, C++ has stricter type requirements than C in many cases, and thus some C code that relies on relaxed type checks will not compile if treated as C++.
so what do you recommend doing? how can i fix this problem?
There are 10 types of people in the world: Those who understand binary, and those who don't...
In C all pointer types are compatible with void *. In C++ they're not. Any place where in C you used this capability, you will have to add a type cast in C++.
eg. in C, this is valid
int *x = malloc(4)
but in C++ you must have
int *x = (int *)malloc(4);
In your case, you're passing a function pointer to a void * type. You need to cast the function pointer to void *, or change the prototype to take something other than void *.
Thanhda wrote:i'm not sure what i am passing it in, i didnt even touch the code, but renamed it to a cpp file and added extern "C" and changed ti to psp-g++
The thing that is different then the previous build is that now there is a psp-setup.c file.
Don't convert it to C++; just compile it as C. BTW, 'extern "C"' doesn't make the code be treated as C code, it just makes the external symbols C-compatible; it is still parsed and error-checked as C++ code.
jsgf wrote:Don't convert it to C++; just compile it as C. BTW, 'extern "C"' doesn't make the code be treated as C code, it just makes the external symbols C-compatible; it is still parsed and error-checked as C++ code.
But how will this work? you cant compile c files using g++. only using gcc. can you compile a mix between c and cpp files? if so can you post a sample of a makefile that will do this.
There are 10 types of people in the world: Those who understand binary, and those who don't...
Thanhda wrote:But how will this work? you cant compile c files using g++. only using gcc. can you compile a mix between c and cpp files? if so can you post a sample of a makefile that will do this.
Make will invoke $(CC) to compile .c files, and $(CXX) to compile .cpp files. If your target depends on a.o, b.o and c.o, and there's an a.c, b.cpp, c.f (Fortran), make will invoke the appropriate compiler for each .o (as soon as someone gets g77 ported to the PSP).
So you shouldn't need to do anything to make this work, except use psp-setup.o rather than psp-setup.c in your link line (ie, get make to compile psp-setup.c separately).
Alternatively, you could change the link line to something like:
Thanhda wrote:But how will this work? you cant compile c files using g++. only using gcc. can you compile a mix between c and cpp files? if so can you post a sample of a makefile that will do this.
Make will invoke $(CC) to compile .c files, and $(CXX) to compile .cpp files. If your target depends on a.o, b.o and c.o, and there's an a.c, b.cpp, c.f (Fortran), make will invoke the appropriate compiler for each .o (as soon as someone gets g77 ported to the PSP).
So you shouldn't need to do anything to make this work, except use psp-setup.o rather than psp-setup.c in your link line (ie, get make to compile psp-setup.c separately).
Alternatively, you could change the link line to something like: