C++ class make the psp turn off

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
laichung
Posts: 123
Joined: Fri May 06, 2005 2:02 pm

C++ class make the psp turn off

Post by laichung »

If found that when I use class in my project, even my file can compile , when it run at the psp , psp will stop response and then turn.

for example , I cant call this : testclass * tc = new testclass();

what's going on ? Is my toolchain out of date or other issues make this error?

Thanks all of your help~
FIF
Posts: 20
Joined: Fri Sep 30, 2005 5:25 am
Location: France

Post by FIF »

hi,

I'm a newbee in psp dev, but my c++ code run fine on my psp. Can you give me more informations about your code/makefile ?
raf
Posts: 57
Joined: Thu Oct 13, 2005 7:38 am

Post by raf »

FIF wrote:hi,

I'm a newbee in psp dev, but my c++ code run fine on my psp. Can you give me more informations about your code/makefile ?
I also use C++ in PSPRadio and it works fine.. Are you compiling against libc or newlib? Try updating the toolchain/sdk...

Raf.
laichung
Posts: 123
Joined: Fri May 06, 2005 2:02 pm

Post by laichung »

actually my code is really normal as a c++ project;
I only define a test class , and try to init it by using "new" operator

and compiler option should not affect the result since "new" operator is just allocate memory for the class. that's mean I cant use "memalloc" too.

may be the problem is due to out date of my toolchain, I will try to update it.
raf wrote:
FIF wrote:hi,

I'm a newbee in psp dev, but my c++ code run fine on my psp. Can you give me more informations about your code/makefile ?
I also use C++ in PSPRadio and it works fine.. Are you compiling against libc or newlib? Try updating the toolchain/sdk...

Raf.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

laichung wrote:and compiler option should not affect the result since "new" operator is just allocate memory for the class.
No, the new operator calls the constructor, too, which could crash and all constructors of objects you've declared as member variables, like "std::string m_name".
laichung
Posts: 123
Joined: Fri May 06, 2005 2:02 pm

Post by laichung »

but my class is just like this

Code: Select all

class testclass{
public:
	char *testc;
};
really simple but create error , even I have updated my toolchain.

Shine wrote:
laichung wrote:and compiler option should not affect the result since "new" operator is just allocate memory for the class.
No, the new operator calls the constructor, too, which could crash and all constructors of objects you've declared as member variables, like "std::string m_name".
laichung
Posts: 123
Joined: Fri May 06, 2005 2:02 pm

Post by laichung »

I think the problem of mine sdk is , malloc is not work , and I dont know why:

Code: Select all

	int *ptr = (int *)malloc(sizeof(int) * 10);
Even this simple code will turn off my psp. Any one know what's going on? Big thanks.
FIF
Posts: 20
Joined: Fri Sep 30, 2005 5:25 am
Location: France

Post by FIF »

Where is the constructor of your class ?
Fanjita
Posts: 217
Joined: Wed Sep 28, 2005 9:31 am

Post by Fanjita »

Are you on firmware 2.0?

Up until the latest EBOOT loader, malloc was broken. It's working fine in loader v0.7, so you should upate if you're on 2.0.
laichung
Posts: 123
Joined: Fri May 06, 2005 2:02 pm

Post by laichung »

constructor is not a must for class.

ANd finally I solve the problem by changing the order of the libraries inculded in the makefile.

thanks all

FIF wrote:Where is the constructor of your class ?
FIF
Posts: 20
Joined: Fri Sep 30, 2005 5:25 am
Location: France

Post by FIF »

laichung wrote:constructor is not a must for class.
Ok, i always write a constructor to initialize some variables into my classes.
We learn all days ;)
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

Are you sure its the class that is turning it off? You could have another error.
laichung
Posts: 123
Joined: Fri May 06, 2005 2:02 pm

Post by laichung »

I have solve the problem by changing the order of the library in the make file. thanks.
The problem is cause by , when it call malloc function , psp will turn off.
I dont know what the order of the library will make this error. (May be the program reference to a wrong function.)
seventoes wrote:Are you sure its the class that is turning it off? You could have another error.
Post Reply