forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problems with classes

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Wed Aug 30, 2006 6:30 pm    Post subject: Problems with classes Reply with quote

Hi folks,

First of all, i know i should only post psp programming specific questions, but i have this simple programming problem of which i can't find anything on the net and i tried looking on this forum and could only find this: http://forums.ps2dev.org/viewtopic.php?t=4956&highlight=classes but that did not work.

I want to use classes in my game but i get these errors:

syntax error before 'Level'
syntax error before '{' token
syntax error before ':' token


here is my Level.cpp code:

Code:
 void Level::Render()
{
// render code
}
void Level::Translate()
{
//translate code
}


and here is my Level.h code:

Code:
class Level{
public:
void Render();
void Translate();
private:
int x,y
};


and i use the -lstdc++ as a parameter for the LIBS = in the makefile.

Code:
TARGET = out
OBJS = $(wildcard *.c)

INCDIR =
CFLAGS = -O2 -G0 -Wall -g
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti -g
ASFLAGS = $(CFLAGS)

LIBDIR =
LDFLAGS =
LIBS = -lstdc++ -g -lpspgu -lpng -lz -lm -lpsputility -lpsprtc -lmad -lpspaudiolib -lpspaudio -lpsppower -lmikmod

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak


what am i doing wrong?

greets ghoti

PS i use Visual C++[/code]
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
Aion



Joined: 24 Jul 2006
Posts: 40
Location: Montreal

PostPosted: Wed Aug 30, 2006 10:35 pm    Post subject: Reply with quote

Is your file extension still "xxx.c"

When programming in C++, you need to use xxx.cc or xxx.cpp to tell the compiler this is not a C file.

Also, you only have a makefile rule for .c files, you need to add one for your xxx.cpp or xxx.cc (whichever name you choose)
Back to top
View user's profile Send private message
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Wed Aug 30, 2006 11:08 pm    Post subject: Reply with quote

well the file where my class is in has the extention cpp but my main file is main.c

what do you mean by the last comment? how can i add those rules?
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Fri Sep 08, 2006 3:50 pm    Post subject: Reply with quote

you must link --> -lstdc++ toward the end of
LIBS to link
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
popcornx



Joined: 14 Mar 2006
Posts: 6

PostPosted: Fri Sep 08, 2006 5:30 pm    Post subject: Reply with quote

did you forget to put a ; after int x,y ???
_________________
23BDFFFCAFB1000423BD0004

"nothing is impossible, not if you could imagen it"
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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