Problems with classes

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

Moderators: cheriff, TyRaNiD

Post Reply
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

Problems with classes

Post by Ghoti »

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? ... ht=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: Select all

 void Level::Render()
{
// render code
}
void Level::Translate()
{
//translate code
}
and here is my Level.h code:

Code: Select all

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

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]
Aion
Posts: 40
Joined: Mon Jul 24, 2006 10:58 pm
Location: Montreal

Post by Aion »

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)
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

Post by Ghoti »

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?
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

you must link --> -lstdc++ toward the end of
LIBS to link
10011011 00101010 11010111 10001001 10111010
popcornx
Posts: 6
Joined: Tue Mar 14, 2006 7:56 am

Post by popcornx »

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

"nothing is impossible, not if you could imagen it"
Post Reply