Zeige Ergebnis 4.711 bis 4.740 von 10174
C/C++ Programming Help Thread
This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; stdio rather defines it, I'd say....
-
05-27-2007, 06:06 PM #4711It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
stdio rather defines it, I'd say.
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-27-2007, 06:20 PM #4712QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
*Smacks head against a wall*
Zitat von Archaemic
-
05-27-2007, 06:25 PM #4713
*helps*
Zitat von PSPJunkie_
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
05-27-2007, 06:37 PM #4714It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
...I'm missing something.
Did I say something stupid without realizing it again?
Forgive me, I'm rather tired right now.
Anyway, I just meant that stdio defines it, but doesn't use it.pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-28-2007, 03:21 AM #4715Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
since i added the mouse part , it's just crashing
yes , i know the code is ugly at the momentCode:int main(SceSize args, void *argp) { string desktopFiles[12][24]; //Storage for floople lloopst loopn desktop dlooprectory int z = 0; //storage for copying strings int x = 10; //storage for x coordinate int y = 10; //storage for y coordinate int mouseX = 10; int mouseY = 10; char imageBuffer[20]; //buffer for image loading char *fileListBuffer; //buffer for file names SceCtrlData pad; sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); Image *iconExample = loadImage("data/desktop/icon.PNG");//the icon Image *iconFolder = loadImage("data/desktop/folder.PNG"); Image *mouse = loadImage("data/desktop/mouse.PNG"); string fileBuffer[222]; //for the filelist //init the garphics initGraphics(); pspDebugScreenInit(); pspDebugScreenClear(); //Load screenshot module LoadStartModule("data/screenshot.prx"); //loopmages load /*for(int loop = 0; loop < sizeof(desktopImages); loop++) { snprintf(imageBuffer ,sizeof(imageBuffer) - 1, "%i.PNG" ,loop); desktopImages[loop] = loadImage(imageBuffer); }*/ desktopBack = loadImage("data/desktop/wallpaper.PNG"); /*if(desktopBack < 0) printf("failed to load image\n"); else printf("Image loaded\n");*/ getFileList("ms0:/"); while(1) { //printf("file paths stored\n"); //printf("Stored to new variabel\n"); blitImage(0,0,desktopBack); for(int loop = 0; loop < sizeof(fileList); loop++ ) { char buffer[10]; if(y!=0) y += 10; if(sizeof(fileList[loop]) > 10) { strncpy(buffer , fileList[loop].c_str() , sizeof(buffer) - 3); strcat(buffer , ".."); fileBuffer[loop] = buffer; } else { fileBuffer[loop] = fileList[loop]; } // if(isFile(fileList[loop])) //{ blitImage(x , y ,iconExample); // } // else //{ //blitImage(x , y ,iconFolder); //} y += 40; printg(x , y , fileBuffer[loop].c_str() , white); if(y > 249) { x += 108; y = 10; } } blitImage(mouseX , mouseY , mouse); flipScreen(); while(1) { sceCtrlReadBufferPositive(&pad, 1); if (pad.Lx < 80) //left { mouseX -= 10; if(mouseX<0) mouseX = 460; break; } if (pad.Lx > 175) //right { mouseX += 10; if(mouseX > 480) mouseX = 0; break; } if (pad.Ly > 175) //down { mouseY -= 10; if(mouseY<0) mouseY = 255; break; } if (pad.Ly < 80) //up { mouseY += 10; if(mouseY > 272) mouseY = 0; break; } if(pad.Buttons & PSP_CTRL_HOME) { sceKernelExitGame(); } } }//end while /* for(int loop = 0; loop < 12; loop++ ) for(int looptwee = 0; looptwee < 24; looptwee++ ) { getImageToBuffer[loop][looptwee] = getImage(desktopFiles[loop][looptwee].c_str()); blitImage(x , y , getImageToBuffer[loop][looptwee]); x += 20; y += 20; }*/ flipScreen(); sceKernelSleepThread(); return 0; }
-
05-28-2007, 06:05 AM #4716QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Unless you know the exact order of files that the preprocessor goes through, that is a dangerous assumption to make. It be better (but still horrendous) to use printfSomeElse or:
Zitat von youresam
That would be better and safer then #defining the name of a stdio function name.Code:#ifdef WINDOWS #define printfDebugText printf #else #define printfDebugText pspDebugScreenPrintf #endif int main() { //..... printfDebugText( "Hello World" ); }
-= Double Post =-
That would just be plain stupid. STL Strings are much safer then char strings by a mile. ¬¬
Zitat von pspballer07
Geändert von yaustar (05-28-2007 um 06:07 AM Uhr) Grund: Automerged Doublepost
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-28-2007, 06:15 AM #4717
I believe the reason people define pspDebugScreenPrintf as printf is to make typing easier, so defining it to a word of about the same length is kinda pointless.
How about..
There, all better.Code:#define omgprintf pspDebugScreenPrintf
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
05-28-2007, 06:16 AM #4718Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Spoiler for main.cpp:
Spoiler for io.cpp:
a bit rewritten and i still dindt saw a mistakes , there are no warnings either
aargh dammit , with copy/paste get every space lost:-(
-
05-28-2007, 06:18 AM #4719QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Stdio declares it as a function prototype, by using the #define printf etc, it is possible that the preprocessor has changed the name of the function prototype depending on the order of files that the preprocessor has gone through.
Zitat von Archaemic
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-28-2007, 07:10 AM #4720It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Eek. That is dangerous. I just changed all of my "printf"s to "say". Not because it's short, but because it makes sense.
However, this is just a temporary solution until my partner creates the bitmap font. SDL_ttf looks a little bit too difficult to work with for what I'm using it for. I'd be doing a lot of metric checking, which could get slow.pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-28-2007, 07:24 AM #4721Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
anyone saw the error in my code yet?
-
05-28-2007, 07:27 AM #4722It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Have you, oh, I don't know, tried running it in PSPLink so you can find out where it crashed? That's generally helpful information.
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-28-2007, 07:46 AM #4723QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
That is what auto completion is for in text editors and IDEs.
Zitat von youresam
From: http://www.psp-programming.com/forum...p?topic=2161.0
Zitat von Yeldarb
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-28-2007, 07:59 AM #4724Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
i dont have a psp
Zitat von Archaemic
-
05-28-2007, 08:05 AM #4725
Or just set up an exception handler and use psp-addr2line? Would be much more helpful
Zitat von Archaemic
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
05-28-2007, 08:19 AM #4726It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
That's also helpful if you're writing a kernel mode application, I guess. Although--
Um...then how are you testing this?
Zitat von hallo007
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-28-2007, 08:33 AM #4727Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
friends / beta testers
i found out it crashes here:
anyone see something?Code:while(1) { blitImage(0 , 0 , desktopBack);//wallpaper for(unsigned int loop = 0; loop < sizeof(fileList); loop++ ) { char buffer[10]; y += 10; //go away from the file name if(sizeof(fileList[loop]) > 10) { strncpy(buffer , fileList[loop].c_str() , sizeof(buffer) - 3); strcat(buffer , ".."); fileBuffer[loop] = buffer; } else { fileBuffer[loop] = fileList[loop]; } if(isFile(fileList[loop])) { blitImage(x , y ,iconExample); } else { blitImage(x , y ,iconFolder); } y += 40; printg(x , y , fileBuffer[loop].c_str() , white); if(y > 249) { x += 108; y = 10; } }
-
05-28-2007, 08:39 AM #4728QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Did you try any debugging methods?
-
05-28-2007, 08:48 AM #4729
If it doesn't compile right it's because you are declaring the unsigned int loop in the for statement. In C, you have to declare it out of or right before the for statement like this:
Zitat von hallo007
Code:unsigned int loop; for(loop = 0; loop<whatever;loop++) { }Current releases:
Icon Action Replacer v1.5- latest release
Current projects:
PSP C++ IDE - Currently v1.6
RPG Paradise - Latest version at my website
-
05-28-2007, 08:50 AM #4730It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Take a look at the code for a moment and you'll see this: "fileBuffer[loop].c_str()". He's using STL strings, which means that this is C++, therefore it's valid. Also, he said it was crashing, which means it must be compiling.
E] Wait, where's buffer defined?
E2] Nevermind, I see it now.Geändert von Archaemic (05-28-2007 um 09:09 AM Uhr)
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-28-2007, 08:55 AM #4731Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
string fileBuffer[222]; ?
no i dindt tried the debugging methods because i havent got a psp and my friends havent got cygwin or the knowledge to use it
-
05-28-2007, 08:57 AM #4732QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
...
Member that little lesson we gave you on using #define, #ifdef, and #ifndef to debug?
-
05-28-2007, 09:01 AM #4733Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
o yeah , wait it is a few pages back
i thought you mean psplink;-)
-= Double Post =-
#define DEBUG
#ifdef DEBUG
...
#endif
but what is this gong to help?
Geändert von hallo007 (05-28-2007 um 09:09 AM Uhr) Grund: Automerged Doublepost
-
05-28-2007, 09:10 AM #4734It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
This is terribly unsafe. If you're going to strcat it, at least make sure to memset buffer to 0 first, otherwise you'll have an instant buffer overflow right there.Code:char buffer[10]; y += 10; //go away from the file name if(sizeof(fileList[loop]) > 10) { strncpy(buffer , fileList[loop].c_str() , sizeof(buffer) - 3); strcat(buffer , ".."); fileBuffer[loop] = buffer; }pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-28-2007, 09:13 AM #4735Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
sizeof(buffer) - 3
i reserved two bytes for the ".."
-
05-28-2007, 09:23 AM #4736QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
You are using C++ strings dammit. Use C++ string operations !!
http://www.cppreference.com/cppstring/append.html
-= Double Post =-
This does not work C++ strings are objects and hold extra data besides the actual char string.Code:if(sizeof(fileList[loop]) > 10)
http://www.cppreference.com/cppstring/length.htmlGeändert von yaustar (05-28-2007 um 09:27 AM Uhr) Grund: Automerged Doublepost
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-28-2007, 09:27 AM #4737It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
That's not where the overflow is coming from. The overflow is coming from the fact that the memory allocated is not necessarily all 0. It could be a (seemingly) random string of characters.
Zitat von hallo007
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-28-2007, 09:40 AM #4738QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Are you serious?
Zitat von hallo007
-
05-28-2007, 10:13 AM #4739Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
yes I am
thnx yauster , i take a look
-
05-28-2007, 10:17 AM #4740It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Why can no one spell yaustar? Honestly, it's not that hard to remember.
Anyway, you'd use the conditionals to print stuff out in debug mode so you can isolate the crash. No PSPLink necessary. It's tedious, but it works.pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ


LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum