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; Hello again, I've been getting some strange errors when I try to compile a project I'm working on. These are ...
-
11-19-2007, 06:56 PM #6901QJ Gamer Blue
- Registriert seit
- Sep 2007
- Beiträge
- 105
- Points
- 3.389
- Level
- 36
- Downloads
- 0
- Uploads
- 0
Hello again,
I've been getting some strange errors when I try to compile a project I'm working on. These are the errors:
I've had these errors before, but I do not remember how I managed to fix it. Does anyone know what these mean? Apparantly these are common when I googled them.Code:psp-gcc -I. -I/cygdrive/c/CSP/cygwin/usr/local/pspdev/psp/sdk/include -O2 -G0 -W all -D_PSP_FW_VERSION=150 -c -o main.o main.c In file included from main.c:10: Game.h:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Game' Game.h:68: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Enemy ' Game.h:118: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Hero ' make: *** [main.o] Error 1
Here is the header file:
The method definitions are in another .c file btw, and main.c has #include "Game.h".Code:// Game.h - Contains the *Game Parent Class* and its *Child Sub-Classes* #ifndef GAME_H_ #define GAME_H_ /*---------------------------------------*/ /* */ /* PARENT CLASS DECLARATION - Game CLASS */ /* */ /*---------------------------------------*/ class Game { // Data Member Declarations public: //Constructor Game(); //Destructor ~Game(); protected: //Methods void HeroIsAttacked(Hero & theHero, Enemy & theEnemy); void EnemyIsAttacked(Enemy & theEnemy, Hero & theHero); //Variables }; /*---------------------------------------*/ /* */ /* CHILD CLASS DECLARATION - Enemy CLASS */ /* */ /*---------------------------------------*/ class Enemy : public Game { // Data Member Declarations public: // Constructor Enemy(char cst_name[15]); // Destructor ~Enemy(); // Methods int defend(); // Vars char enemyName[]; int mE_attackPts; int mE_healthPts; int mE_defendPts; }; /*---------------------------------------*/ /* */ /* CHILD CLASS DECLARATION - Hero CLASS */ /* */ /*---------------------------------------*/ class Hero : public Game { // Data Member Declarations public: // Constructor Hero(bool isMale); // Destructor ~Hero(); // Methods int defend(); // Vars int mH_attackPts; int mH_healthPts; int mH_defensePts; bool mH_gender; }; #endif
Any ideas?
-
11-19-2007, 07:27 PM #6902It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
The file you've provided has less lines than the output suggests. Are you sure it's the right file?
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
11-19-2007, 10:20 PM #6903Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
I found a solution , when I compille it as c , it'd just works fine
Zitat von hallo007
any reason it doesn't works with c++?
-
11-19-2007, 10:39 PM #6904QJ Gamer Blue
- Registriert seit
- Sep 2007
- Beiträge
- 105
- Points
- 3.389
- Level
- 36
- Downloads
- 0
- Uploads
- 0
Yes I'm sure. I'm not sure if you're the one I mentioned to that sometimes the lines are incorrect. Like if it says error on a string in line 32, when line 32 is blank. I have no idea why it does that. : /
Zitat von Archaemic
-
11-20-2007, 01:07 AM #6905QJ Gamer Bronze

- Registriert seit
- Aug 2007
- Ort
- Australia
- Beiträge
- 659
- Points
- 8.045
- Level
- 60
- Downloads
- 0
- Uploads
- 0
Hey everyone, i was just wondering if anyone knew a library that has mp3 playback othre than mp3player.c. thanks
-
11-20-2007, 02:10 AM #6906QJ 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++ so your files need to be .cpp not .c
Zitat von Gusjdt
[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]
-
11-20-2007, 03:45 AM #6907QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Sorry, I was actually referring to JaSo PSP, not you. You gave him lots of hints of what he could do better and had a small mistake left in your code - which he just copied and pasted and then wondered why it didn't work. That's stupid. Basically, with this mentality, you could have given him the code for a bricker and he would have tested it, seeing how his PSP gets bricked just because he didn't take the effort to see what the code actually does.
Zitat von Archaemic
And the error was pretty obvious if you know what you're doing and trying to do - at least you seem to, seeing the corrected version.Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.
-
11-20-2007, 05:57 AM #6908QJ Gamer Blue
- Registriert seit
- Sep 2007
- Beiträge
- 105
- Points
- 3.389
- Level
- 36
- Downloads
- 0
- Uploads
- 0
Thanks again Yaustar, I appreciate it.
Zitat von yaustar
I knew it was something silly...
-
11-20-2007, 06:17 AM #6909
Guys I'll post this again, as the last one got one answer, but when I tried to contact the guy who answered, I got no response.
+++++++++++++++
Hi, is somebody here using DSX to display stuff on the XMB?
I'm currently working on a plugin, and am finding that it's flickering a bit. Also, it's conflicting with some items on the XMB, such as video and browser.
I thought about either disabling it when loading video or browser, or find a way to fix it.
Also the flickering thing is very annoying
Does anyone know how to fix that?
CheersPlaco23
Why not donate and become part of this selected list?Spoiler for Wanna see my Apps?:Spoiler for Donators:
-
11-20-2007, 06:47 AM #6910QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Conflicting with browser/video: Plugin takes too much memory, code better
Flickering: Hook sceDisplaySetFrameBuf and do your drawing before calling the original functionRaphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.
-
11-20-2007, 10:30 AM #6911QJ Gamer Green
- Registriert seit
- Apr 2006
- Ort
- England ~¦¦¦|+|¦¦¦~
- Beiträge
- 1.112
- Points
- 9.165
- Level
- 64
- My Mood
-
- Downloads
- 0
- Uploads
- 0
I changed 'i' to '&i' anyway, i just didn't mention it here...
...Just Returned To The Scene...
-
11-20-2007, 10:34 AM #6912
Thanks for that Raphael. I know you answered me on the other forum about this, but my pc has been a bit flakey lately. Sorry for not sending you another message.
Zitat von Raphael
In fact, I think it's the vsxlib that uses too much memory, as I'm sure my plugin is very light.
I tried to use sceDisplaySetFrameBuf, but it didn't really change much. I don't know if I'm using it the wrong way, but basically, even if I print a basic hello world on the screen using vsx ans try to use sceDisplaySetFrameBuf, I still have the flickering.
Do you know what else it could be? Or, do you have any example using this lib that doesn't flicker and doesn't crash the browser?
Would you suggest a library change (from vsx to another)?
Thank you very much!Placo23
Why not donate and become part of this selected list?Spoiler for Wanna see my Apps?:Spoiler for Donators:
-
11-20-2007, 11:44 AM #6913QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
By "hooking" I meant you should use something like API hook by Tyranid or write your own function hooking to be able to intercept the firmwares own calls to sceDisplaySetFramebuf and get your own drawing done before the VSH swaps the framebuffer. By doing that you won't get any flickering ever (see JoySens plugin).
If you don't understand a single word of that - well, then you better just live with the flickering for the moment.Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.
-
11-20-2007, 03:28 PM #6914lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
How do I write a single bit to a file?
-
11-20-2007, 03:39 PM #6915It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
You can't. You can modify the byte that you want, but you can't modify bit at a time.
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
11-20-2007, 11:32 PM #6916
- Registriert seit
- Sep 2007
- Beiträge
- 16
- Points
- 3.026
- Level
- 33
- Downloads
- 0
- Uploads
- 0
im making an app and my menu is like this:
this is taken from Cory's Pandora Battert Menu source and what i want to know is how can I make the selected menu item higlighted in a color like this:Code:void refreshArrow(void) { setXY(2, rowprev + row_offset); printf(" "); setXY(2, row + row_offset); printf("->"); } main { ...... row = 0; rowprev = 0; maxrows = 4; printf("* Start "); printf("\n* Settings"); printf("\n* Choose Playlist"); printf("\n* Exit"); refreshArrow(); unsigned int b; b = wait_press(PSP_CTRL_UP|PSP_CTRL_DOWN|PSP_CTRL_CROSS); wait_release(PSP_CTRL_UP|PSP_CTRL_DOWN|PSP_CTRL_CROSS); if (b & PSP_CTRL_DOWN) { rowprev = row; if (row == maxrows) row = 0; else if (row == (maxrows - 1)) row += 1; else row++; refreshArrow(); } else if (b & PSP_CTRL_UP) { rowprev = row; if (row == 0) row = maxrows; else if (row == maxrows) row -= 1; else row--; refreshArrow(); } else if (b & PSP_CTRL_CROSS) { if (row == maxrows) { setXY(5, 25); printf("Good Bye"); sceKernelDelayThread(3 * 1000 * 1000); vshKernelExitVSHVSH(NULL); } ..... rest of code
so its not like this:Code:Start Settings Choose Playlist Exit
Im sorry but Im really a noob.Code:Start -> Settings Choose Playlist Exit
-
11-20-2007, 11:48 PM #6917QJ Gamer Silver
- Registriert seit
- Feb 2007
- Ort
- Melbourne, Australia
- Beiträge
- 1.773
- Points
- 8.717
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
read here:
HERE
it is about creating a menu.WHA!?
-
11-20-2007, 11:51 PM #6918
- Registriert seit
- Sep 2007
- Beiträge
- 16
- Points
- 3.026
- Level
- 33
- Downloads
- 0
- Uploads
- 0
I don't need to know how to make a menu, as you can see I already Have 1. I just want to make it look nicer.
-
11-20-2007, 11:59 PM #6919QJ Gamer Silver
- Registriert seit
- Feb 2007
- Ort
- Melbourne, Australia
- Beiträge
- 1.773
- Points
- 8.717
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
if you use that code you can use colours, it was just an option...
WHA!?
-
11-21-2007, 12:04 AM #6920
- Registriert seit
- Sep 2007
- Beiträge
- 16
- Points
- 3.026
- Level
- 33
- Downloads
- 0
- Uploads
- 0
But then I have to rewrite alot of code just for some simple colors. I just want a simple sloution to highlight the selected item.
-
11-21-2007, 12:05 AM #6921QJ Gamer Silver
- Registriert seit
- Feb 2007
- Ort
- Melbourne, Australia
- Beiträge
- 1.773
- Points
- 8.717
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Okay, I am trying to make a little game but i keep getting an error..
(main function code)
Zitat von Error
Code:int main(void) { pspDebugScreenInit(); SetupCallbacks(); SceCtrlData pad; int ok = 1; int x = 100; int y = 100; int width = 50; int height = 50; Color red = RGB(0, 255, 0); Image* Background; Background = loadImage("./Images/Background.png"); while(1) { sceCtrlReadBufferPositive(&pad, 1); blitAlphaImageToScreen(0, 0 , 480, 272, Background, 0, 0); // move square left if(pad.Buttons & PSP_CTRL_SQUARE) { x = x--; } // move square right if(pad.Buttons & PSP_CTRL_CIRCLE) { x = x++; } // move square up if(pad.Buttons & PSP_CTRL_TRIANGLE) { y = y--; } // move square down if(pad.Buttons & PSP_CTRL_CROSS) { y = y++; } // draw our little square! if(ok >= 1){ fillScreenRect(red, x, y, width, height); } sceDisplayWaitVblankStart(); flipScreen(); } sceKernelSleepThread(); return 0; }WHA!?
-
11-21-2007, 12:51 AM #6922
Well that's basical logic, but I'll tell you how to do giving you the logic and not simply the code.
Zitat von pspN00bDevoloper
Basically the idea is:
You have a loop right?
In the loop, you need to check the cursor position everytime.
I see that you're doing that with the "row" variable.
You can just put an if around each of the items in the menu like
if(row == 1)
set other colour here
printf("Start ");
set colour back to the original
if(row == 2)
set other colour here
printf("item2 ");
set colour back to the original
Then you'll have colours on your menu
You shouldn't just copy things from other soucrs, it's so much more fun if you do it from scratch.
Also I'm sure that there's some code in your menu that you don't even know why is there.
If you need another example, post back, but I think you should try to figure out by yourself with the logic I gave you.
CheersPlaco23
Why not donate and become part of this selected list?Spoiler for Wanna see my Apps?:Spoiler for Donators:
-
11-21-2007, 02:29 AM #6923QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
And any similar code is undefined because you post evaluate x, assign it to itself and then decrement itself. The undefined part comes in the order of the operations differ with different compilers.Code:x = x--;
What you want is either:
orCode:x = x - 1;
Code:--x;
[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]
-
11-21-2007, 02:34 AM #6924QJ Gamer Silver
- Registriert seit
- Feb 2007
- Ort
- Melbourne, Australia
- Beiträge
- 1.773
- Points
- 8.717
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
okay thanks :), also where can i find a basic tutorial on how to make a PRX? (one for on the XMB (VSH)?)
WHA!?
-
11-21-2007, 02:39 AM #6925
Just look for VSX or VSH Blit
Zitat von BigSanFrey
There's some examples, and it's pretty easy.
Also, you may look at VSH Bitter 0.2 posted on this topic somewherePlaco23
Why not donate and become part of this selected list?Spoiler for Wanna see my Apps?:Spoiler for Donators:
-
11-21-2007, 03:31 AM #6926I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
I want to display a volume bar much like the PSPs own, but I'm not sure how to check what the volume is, the only examples I have found don't actually do what I need they appear to change a different volume, I want, for example, the left and right shoulder buttons to do what the + and - volume buttons do, but to also display that same bar in an app.
Sorry if I didn't explain that well, I'm not sure how to explain it, if none of that made sense I'll try and think of another way of saying it.
-Aura
-
11-21-2007, 03:34 AM #6927QJ Gamer Green
- Registriert seit
- Sep 2006
- Ort
- Cape Town, South Africa
- Beiträge
- 714
- Points
- 5.795
- Level
- 49
- Downloads
- 0
- Uploads
- 0
@BigSanFrey: Why are you trying to access pad and y in your CallbackThread function?
-
11-21-2007, 03:35 AM #6928
Aura, have you tried looking at the User Udio Library? (http://psp.jim.sh/pspsdk-doc/group__Audio.html) well I believe so, but thought it'd worth sending the link.
Zitat von Auraomega
I think you need to know what the channel is. As far as I'm aware, there's 8 chanels. And *if* I'm not mistaken, you could just test'em too see if the volume increases or decreses. Then you'd need to be able to siplay the actual barPlaco23
Why not donate and become part of this selected list?Spoiler for Wanna see my Apps?:Spoiler for Donators:
-
11-21-2007, 03:42 AM #6929I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
I was using that library before, I guess it would make logical sense to check all of the channels, one is bound to be the correct one.
Displaying the bar shouldn't be too hard, if worst comes to worst, I guess I could simply make my own which in the end is what I was going to do, it just means I go from A to C without B
I'll try all that later when I get access to a compiler, thanks for that :)
-Aura
-
11-21-2007, 07:44 AM #6930QJ Gamer Green
- Registriert seit
- Sep 2006
- Ort
- Cape Town, South Africa
- Beiträge
- 714
- Points
- 5.795
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Okay, I need some help with something. I need to get a list of files in a directory. I've found how do it using sceIoDopen and so on, but that requires the path to that directory to be hard-coded. For example, I might expect the directory to be in ms0:/PSP/GAME/blah/huh/, but the user might have placed the eboot in GAME150, so it would fail. For normal file reading, I've used the f-something functions (fopen, fread etc.) instead of the SceIo* functions, so I can use relative paths. But how do I do this for finding the files in a directory?


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