| View previous topic :: View next topic |
| Author |
Message |
laichung
Joined: 06 May 2005 Posts: 123
|
Posted: Fri Oct 21, 2005 5:53 pm Post subject: C++ class make the psp turn off |
|
|
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 |
|
 |
FIF
Joined: 30 Sep 2005 Posts: 20 Location: France
|
Posted: Fri Oct 21, 2005 10:10 pm Post subject: |
|
|
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 |
|
 |
raf
Joined: 13 Oct 2005 Posts: 57
|
Posted: Sat Oct 22, 2005 1:21 am Post subject: |
|
|
| 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 |
|
 |
laichung
Joined: 06 May 2005 Posts: 123
|
Posted: Sat Oct 22, 2005 11:41 am Post subject: |
|
|
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 |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Sun Oct 23, 2005 1:11 am Post subject: |
|
|
| 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 |
|
 |
laichung
Joined: 06 May 2005 Posts: 123
|
Posted: Mon Oct 24, 2005 11:55 am Post subject: |
|
|
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 |
|
 |
laichung
Joined: 06 May 2005 Posts: 123
|
Posted: Mon Oct 24, 2005 1:43 pm Post subject: |
|
|
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 |
|
 |
FIF
Joined: 30 Sep 2005 Posts: 20 Location: France
|
Posted: Mon Oct 24, 2005 7:52 pm Post subject: |
|
|
| Where is the constructor of your class ? |
|
| Back to top |
|
 |
Fanjita
Joined: 28 Sep 2005 Posts: 217
|
Posted: Mon Oct 24, 2005 11:02 pm Post subject: |
|
|
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 |
|
 |
laichung
Joined: 06 May 2005 Posts: 123
|
Posted: Tue Oct 25, 2005 1:42 pm Post subject: |
|
|
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 |
|
 |
FIF
Joined: 30 Sep 2005 Posts: 20 Location: France
|
Posted: Tue Oct 25, 2005 5:24 pm Post subject: |
|
|
| 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 |
|
 |
seventoes
Joined: 02 Oct 2005 Posts: 79
|
Posted: Sun Oct 30, 2005 5:39 am Post subject: |
|
|
| Are you sure its the class that is turning it off? You could have another error. |
|
| Back to top |
|
 |
laichung
Joined: 06 May 2005 Posts: 123
|
Posted: Mon Oct 31, 2005 3:51 pm Post subject: |
|
|
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 |
|
 |
|