GP32 Using C++ In The Gp32


Puck2099

Certified Guru
Joined
Oct 22, 2004
Messages
422
Location
Madrid, Spain
Website
www.gp32wip.com
Hi,

I have read in several sites that C++ is incompatible with GP32's official SDK due to problems with "new", "delete" and others memory management functions.

I think that using Mirko's SDK there will be no problems but I am more comfortable with the official SDK.

I need to make use of all C++ features (classes, objects...) because I want to port a C++ project that makes use of them. Does anyone know if there is any way to do it using official SDK?, maybe remaping memory management functions?

Thanks a lot :)
 
Puck2099 posted on Mar 23 2005 at 11:46 AM said:
Hi at

I have read in several sites that C++ is incompatible with GP32's official SDK due to problems with "new", "delete" and others memory management functions.

I think that using Mirko's SDK there will be no problems but I am more comfortable with the official SDK.

I need to make use of all C++ features (classes, objects...) because I want to port a C++ project that makes use of them. Does anyone know if there is any way to do it using official SDK?, maybe remaping memory management functions?

Thanks a lot :)

It is not possible to port a c++ programm to c, couse c++ is a lot more than the new and delete commands.
c++ is a OO programming language, this means it is working in Objects, c can also handel objects (with structs) but it is not eaven far the same.
If the project is small, try to rewrite it to c, or forgett about using gp32 official sdk.
If the project is big, try to use the gcc/c++ toolchain. with newlib.

greets,
 
Last edited by a moderator:
mr.mirko posted on Mar 23 2005 at 02:36 PM said:
It is not possible to port a c++ programm to c, couse c++ is a lot more than the new and delete commands.
c++ is a OO programming language, this means it is working in Objects, c can also handel objects (with structs) but it is not eaven far the same.
If the project is small, try to rewrite it to c, or forgett about using gp32 official sdk.
If the project is big, try to use the gcc/c++ toolchain. with newlib.

greets,

Mirko, I think that I haven't expressed correctly. I don't want to port a c++ program to c, I know that is impossible without recoding all, I wanted to say that I want to port a c++ program to GP32, but manteining c++, rewriting functions related to video, sound, etc. to GP32 compatible ones.

I understand from your words that c++ is not possible using GP32 official SDK, isn't it?

Finally, could you tell me a bit more about newlib?. I use this toolchain but I don't know if it make use of newlib.

I'm sorry if my bad English can make understanding mistakes :(

Thanks again
 
Last edited by a moderator:
There are issues with using GPSDK and C++ _and_ with standard C! If the standard C issues are handled then pretty much all of C++ works, except for static initialization.

To get standard C working properly you need a port of newlib. Many toolchains have done this, but in a non-GPSDK compatible way. To be GPSDK compatible the memory allocation from malloc and gmalloc have to work together. The easiest way to do that is to implement malloc in terms of gmalloc. Or to be more specific _sbrk in newlib. To port newlib you basically need to write a syscall.c file. If you grab the source for my port of atari800 emulator you can see an example syscall.c. I just allocate a large chunk of memory with gpmalloc and use this as a large buffer for the C malloc! Course you have to know approximately how much memory you'll use from the GPSDK and how much via C/C++ malloc/new calls.

There is a final step to make C++ static constructors work. You can use a spec file _or_ manually link crti.o and crtbegin.o before your objects. The former is best.

Good luck,

Mark
 
C++ with official sdk work, yAnl is write with that, using ads (arm developer suite)
there aren't new and delete, but class and other stuff work fine

i don't know how rewrite a new operator but you can replace it with that :

patterns = (pattern *)malloc(numPattern*sizeof(pattern)) ; // alloc objects
for(int c=0;c<numPattern;c++)
{ patterns[c].pattern(...) ; // and launch constructor
};
 
Mr.Mirko's SDK has an example program that shows how to compile a C++ fxe.

Edit: Yeah, I should read posts more carefully, you said that already. :p
 
Back
Top