 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Rav
Joined: 01 Jun 2007 Posts: 11 Location: France
|
Posted: Wed Jul 04, 2007 7:07 am Post subject: [Solved]Hum... expected unqualified-id before ‘asm’ ? |
|
|
Hi !
I'm a noob with C++ but I think I have a pretty good understandind of C, Java, C# and overs.
When I try to compile this :
Sprite.h
| Code: |
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "Fonctions/graphics.h"
class Sprite
{
private:
Image * image;
public:
Sprite();
};
|
Sprite.cpp
| Code: |
#include "Sprite.hpp"
#define printf pspDebugScreenPrintf
Sprite::Sprite()
{
initGraphics();
image = loadImage("Images/Joueur/Lancer01_Down.png");
int x = 0;
int y = 0;
blitAlphaImageToScreen(0,0,29,44,image, x, y);
flipScreen();
}
PSP_MODULE_INFO("Sprite", 0, 1, 1);
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int main()
{
pspDebugScreenInit();
SetupCallbacks();
new Sprite();
sceKernelSleepThread();
return 0;
}
|
My Makefile is :
| Code: |
TARGET = Sprite
OBJS = Fonctions/framebuffer.o Fonctions/graphics.o Sprite.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lpspgu -lpng -lz -lm -lstdc++
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Sprite
PSPSDK = /usr/local/pspdev/psp/sdk/
include $(PSPSDK)/lib/build.mak
|
I've got this error :
psp-g++ -I. -I/usr/local/pspdev/psp/sdk//include -O2 -G0 -Wall -I. -I/usr/local/pspdev/psp/sdk//include -O2 -G0 -Wall -fno-exceptions -fno-rtti -c -o Sprite.o Sprite.cpp
Sprite.cpp:7: erreur: expected unqualified-id before ‘asm’
make: *** [Sprite.o] Erreur 1
[1]+ Done clear
I don't have a clue about where I made an error, if someone could help me ^^
Last edited by Rav on Thu Jul 05, 2007 6:50 am; edited 3 times in total |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Wed Jul 04, 2007 7:44 am Post subject: |
|
|
| You forgot a semicolon after the last closing brace in sprite.h. |
|
| Back to top |
|
 |
Rav
Joined: 01 Jun 2007 Posts: 11 Location: France
|
Posted: Wed Jul 04, 2007 8:00 am Post subject: Wow |
|
|
Wow, thanks, I didn't notice that I had to put a semicolon. I guess it's because I usually use Java.
Thanks.
Now I have an other error:
| Code: | Sprite.o: dans la fonction « main »:
Sprite.cpp:(.text+0x80): référence indéfinie vers « initGraphics() »
Sprite.cpp:(.text+0x8c): référence indéfinie vers « loadImage(char const*)»
Sprite.cpp:(.text+0xb0): référence indéfinie vers « blitAlphaImageToScreen(int, int, int, int, Image*, int, int)»
Sprite.cpp:(.text+0xb8): référence indéfinie vers « flipScreen() »
collect2: ld a retourné 1 code d'état d'exécution
make: *** [Sprite.elf] Erreur 1
|
"référence indéfinie vers" means "undefined reference to"
Does this mean that I have an error with my header because I use these funtions there ?
These functions are in C files but the error is the same when I had
| Code: |
extern "C"
{
extern void initGraphics();
extern Image * loadImage(const char* filename);
extern void blitAlphaImageToScreen(int sx, int sy, int width, int height, Image* source, int dx, int dy);
extern initGraphics()void flipScreen();
} |
So I don't know where to look -_-
Sorry for being that noob. |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Thu Jul 05, 2007 1:59 am Post subject: |
|
|
You are calling functions you never defined.
Write them and add the file to your Makefile on the OBJS line. |
|
| Back to top |
|
 |
Rav
Joined: 01 Jun 2007 Posts: 11 Location: France
|
Posted: Thu Jul 05, 2007 2:09 am Post subject: Hum.. |
|
|
These functions are defined in the directory "Fonctions", headers and source code.
I added them in the makefile:
OBJS = Fonctions/framebuffer.o Fonctions/graphics.o Sprite.o
But the error is the same.
If my memory is good, adding include "X" in a header file will add X to the source code file which include this header file, right ?
The files in the direction "Fonctions" are here.
I moved the constructor to the source code file. |
|
| Back to top |
|
 |
Rav
Joined: 01 Jun 2007 Posts: 11 Location: France
|
Posted: Thu Jul 05, 2007 6:48 am Post subject: Roh |
|
|
Hum, I found the problem(s).
The first one is that the makefile doesn't rebuild the .o associated with the .c I changed.
The second one is that, in the Sprite.h I should have included the graphics.h this way :
| Code: | extern "C"
{
#include "Fonctions/graphics.h"
} |
That's all ! |
|
| Back to top |
|
 |
|
|
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
|