forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

C++ class make the psp turn off

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
laichung



Joined: 06 May 2005
Posts: 123

PostPosted: Fri Oct 21, 2005 5:53 pm    Post subject: C++ class make the psp turn off Reply with quote

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~
Back to top
View user's profile Send private message
FIF



Joined: 30 Sep 2005
Posts: 20
Location: France

PostPosted: Fri Oct 21, 2005 10:10 pm    Post subject: Reply with quote

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 ?
Back to top
View user's profile Send private message MSN Messenger
raf



Joined: 13 Oct 2005
Posts: 57

PostPosted: Sat Oct 22, 2005 1:21 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
laichung



Joined: 06 May 2005
Posts: 123

PostPosted: Sat Oct 22, 2005 11:41 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Sun Oct 23, 2005 1:11 am    Post subject: Reply with quote

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".
Back to top
View user's profile Send private message
laichung



Joined: 06 May 2005
Posts: 123

PostPosted: Mon Oct 24, 2005 11:55 am    Post subject: Reply with quote

but my class is just like this

Code:
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".
Back to top
View user's profile Send private message
laichung



Joined: 06 May 2005
Posts: 123

PostPosted: Mon Oct 24, 2005 1:43 pm    Post subject: Reply with quote

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

Code:

   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.
Back to top
View user's profile Send private message
FIF



Joined: 30 Sep 2005
Posts: 20
Location: France

PostPosted: Mon Oct 24, 2005 7:52 pm    Post subject: Reply with quote

Where is the constructor of your class ?
Back to top
View user's profile Send private message MSN Messenger
Fanjita



Joined: 28 Sep 2005
Posts: 217

PostPosted: Mon Oct 24, 2005 11:02 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
laichung



Joined: 06 May 2005
Posts: 123

PostPosted: Tue Oct 25, 2005 1:42 pm    Post subject: Reply with quote

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 ?
Back to top
View user's profile Send private message
FIF



Joined: 30 Sep 2005
Posts: 20
Location: France

PostPosted: Tue Oct 25, 2005 5:24 pm    Post subject: Reply with quote

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 ;)
Back to top
View user's profile Send private message MSN Messenger
seventoes



Joined: 02 Oct 2005
Posts: 79

PostPosted: Sun Oct 30, 2005 5:39 am    Post subject: Reply with quote

Are you sure its the class that is turning it off? You could have another error.
Back to top
View user's profile Send private message
laichung



Joined: 06 May 2005
Posts: 123

PostPosted: Mon Oct 31, 2005 3:51 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group