[Solved]Hum... expected unqualified-id before ‘asm’ ?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Rav
Posts: 11
Joined: Fri Jun 01, 2007 2:56 am
Location: France
Contact:

[Solved]Hum... expected unqualified-id before ‘asm’ ?

Post by Rav »

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: Select all

#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
&#123;
	private&#58;
		Image * image;
	
	public&#58;
		Sprite&#40;&#41;;
&#125;;
Sprite.cpp

Code: Select all

#include "Sprite.hpp"

#define printf pspDebugScreenPrintf

Sprite&#58;&#58;Sprite&#40;&#41;
&#123;
	initGraphics&#40;&#41;;
	image = loadImage&#40;"Images/Joueur/Lancer01_Down.png"&#41;;
	int x = 0;
	int y = 0;
	blitAlphaImageToScreen&#40;0,0,29,44,image, x, y&#41;;
	flipScreen&#40;&#41;;
&#125;

PSP_MODULE_INFO&#40;"Sprite", 0, 1, 1&#41;; 

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41; &#123;
	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
	int cbid;
	cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;
	sceKernelSleepThreadCB&#40;&#41;;
	return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41; &#123;
	int thid = 0;
	thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
	if&#40;thid >= 0&#41; &#123;
		sceKernelStartThread&#40;thid, 0, 0&#41;;
	&#125;
	return thid;
&#125;

int main&#40;&#41;
&#123;
	pspDebugScreenInit&#40;&#41;;
	SetupCallbacks&#40;&#41;;
	
	new Sprite&#40;&#41;;
	
	sceKernelSleepThread&#40;&#41;;
	
	return 0;
&#125;
My Makefile is :

Code: Select all

TARGET = Sprite
OBJS = Fonctions/framebuffer.o Fonctions/graphics.o Sprite.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

LIBDIR =
LIBS = -lpspgu -lpng -lz -lm -lstdc++
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Sprite

PSPSDK = /usr/local/pspdev/psp/sdk/
include $&#40;PSPSDK&#41;/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.
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

You forgot a semicolon after the last closing brace in sprite.h.
Rav
Posts: 11
Joined: Fri Jun 01, 2007 2:56 am
Location: France
Contact:

Wow

Post by Rav »

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: Select all

Sprite.o&#58; dans la fonction « main »&#58;
Sprite.cpp&#58;&#40;.text+0x80&#41;&#58; référence indéfinie vers « initGraphics&#40;&#41;    »
Sprite.cpp&#58;&#40;.text+0x8c&#41;&#58; référence indéfinie vers « loadImage&#40;char const*&#41;»
Sprite.cpp&#58;&#40;.text+0xb0&#41;&#58; référence indéfinie vers « blitAlphaImageToScreen&#40;int, int, int, int, Image*, int, int&#41;»
Sprite.cpp&#58;&#40;.text+0xb8&#41;&#58; référence indéfinie vers « flipScreen&#40;&#41;    »
collect2&#58; ld a retourné 1 code d'état d'exécution
make&#58; *** &#91;Sprite.elf&#93; 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: Select all

extern "C"
&#123;
	extern void initGraphics&#40;&#41;;
	extern Image * loadImage&#40;const char* filename&#41;;
	extern void blitAlphaImageToScreen&#40;int sx, int sy, int width, int height, Image* source, int dx, int dy&#41;;
	extern initGraphics&#40;&#41;void flipScreen&#40;&#41;;
&#125;
So I don't know where to look -_-

Sorry for being that noob.
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

You are calling functions you never defined.
Write them and add the file to your Makefile on the OBJS line.
Rav
Posts: 11
Joined: Fri Jun 01, 2007 2:56 am
Location: France
Contact:

Hum..

Post by Rav »

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.
Rav
Posts: 11
Joined: Fri Jun 01, 2007 2:56 am
Location: France
Contact:

Roh

Post by Rav »

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: Select all

extern "C"
&#123;
   #include "Fonctions/graphics.h"
&#125;
That's all !
Post Reply