Discuss the development of new homebrew software, tools and libraries.
Moderators: cheriff , TyRaNiD
jojojoris
Posts: 255 Joined: Sun Mar 30, 2008 4:06 am
Post
by jojojoris » Mon Apr 27, 2009 3:57 am
I have some strange problems.
Code: Select all
game::game() {
notenames[1] = "A";
notenames[2] = "A#";
notenames[3] = "B";
notenames[4] = "C";
notenames[5] = "C#";
notenames[6] = "D";
notenames[7] = "D#";
notenames[8] = "E";
notenames[9] = "F";
notenames[10] = "F#";
notenames[11] = "G";
notenames[12] = "G#";
running = true;
}
bool game::run() {
while (running) {
pspDebugScreenSetXY(0,0);
pspDebugScreenPrintf("-%s-",notenames[2]);
for(short i=0;i<5;i++)sceDisplayWaitVblankStart();
}
return true;
}
and in the main:
The output has strange behaviour.
The output is:
And the background had a b=green/blue collor. I always tought that the background collor should be black by default.
Now my question:
What did i do wrong?
I want the output:
Last edited by
jojojoris on Mon Apr 27, 2009 4:22 am, edited 1 time in total.
Code: Select all
int main(){
SetupCallbacks();
makeNiceGame();
sceKernelExitGame();
}
sauron_le_noir
Posts: 203 Joined: Sat Jul 05, 2008 8:03 am
Post
by sauron_le_noir » Mon Apr 27, 2009 4:19 am
what is the type of notename ? String ?
where is the new of the class game?
before your constructor has been called is must been instancied by a new no ?
Last edited by
sauron_le_noir on Mon Apr 27, 2009 4:21 am, edited 1 time in total.
jojojoris
Posts: 255 Joined: Sun Mar 30, 2008 4:06 am
Post
by jojojoris » Mon Apr 27, 2009 4:21 am
sauron_le_noir wrote: what is the type of notename ? String ?
where is the new of the class GG ?
before your constructor has been called is must been instancied by a new no ?
ooo
Sorry i forget to tell
its a char *
lets say notenames is an array of (char *)
Code: Select all
int main(){
SetupCallbacks();
makeNiceGame();
sceKernelExitGame();
}
sauron_le_noir
Posts: 203 Joined: Sat Jul 05, 2008 8:03 am
Post
by sauron_le_noir » Mon Apr 27, 2009 4:28 am
why not using string in your c++ program string type is a object type
char * are pointer used just for compatibility with C
to use your string on operating function like the DebugPrintf just use the c_str() function provide by C++.
With string the compiler can at compile time perform a lot of checks.
on pointer ... it's at runtime and you can have lot of memory leaks ;)
At this site you've got a tuto to write a c++ program on psp
http://www.ghoti.nl/PSPtutorial2.php
jojojoris
Posts: 255 Joined: Sun Mar 30, 2008 4:06 am
Post
by jojojoris » Mon Apr 27, 2009 7:26 pm
When i use the string type my program crashes and it when i use psp-addr2line is said:
Code: Select all
C:\projects\PSPGuitarHelper>psp-addr2line -e pspgg.elf 0x00002EA0
x:/workspace/minpspw/psp/build/gcc-4.3.3/psp/libstdc++-v3/include/bits/basic_string.h:316
I found out that when i use memset it all works well.
Code: Select all
game::game() {
memset(notenames,0,18);
notenames[1] = (char*)"A";
notenames[2] = (char*)"A#";
notenames[3] = (char*)"B";
notenames[4] = (char*)"C";
notenames[5] = (char*)"C#";
notenames[6] = (char*)"D";
notenames[7] = (char*)"D#";
notenames[8] = (char*)"E";
notenames[9] = (char*)"F";
notenames[10] = (char*)"F#";
notenames[11] = (char*)"G";
notenames[12] = (char*)"G#";
running = true;
}
Your site looks usefull. I''m new at object orientating proramming.
Code: Select all
int main(){
SetupCallbacks();
makeNiceGame();
sceKernelExitGame();
}
sauron_le_noir
Posts: 203 Joined: Sat Jul 05, 2008 8:03 am
Post
by sauron_le_noir » Tue Apr 28, 2009 4:02 am
variable not initialized = memory leak = fatal error
for the string it is strange i have no problem with it i use list,arrary etc ...
do you have the last toolchain ? and the last gcc ?
Are you compiling under windows -> if yes using the heimdall implementation
of the cygwin one if under linux witch gcc has compile the cross compiler
psp-gcc , is the version of psp-gcc (GCC) -->4.3.2