using namespace or class?

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

Moderators: cheriff, TyRaNiD

Post Reply
x2cube
Posts: 7
Joined: Tue Oct 11, 2005 5:10 pm

using namespace or class?

Post by x2cube »

How do I put a namespace or class in my project?

I tried this:

Code: Select all

namespace ABC
{
class PSPabc
{
int i;
};
}
but some errors arose:

Code: Select all

psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall   -c -o main.o main.c
In file included from main.c:20:
main.h:1: error: syntax error before 'ABC'
main.h:2: error: syntax error before '{' token
make: *** [main.o] Error 1
what should I do?
CyberBill
Posts: 86
Joined: Tue Jul 26, 2005 3:53 pm
Location: Redmond, WA

Post by CyberBill »

Dont use .c, use .cpp.

You probably need to change some stuff in your makefile to allow for C++ code, too.

But that is the correct syntax.
x2cube
Posts: 7
Joined: Tue Oct 11, 2005 5:10 pm

Post by x2cube »

CyberBill wrote:Dont use .c, use .cpp.

You probably need to change some stuff in your makefile to allow for C++ code, too.

But that is the correct syntax.
thanks for the help!
Paco
Posts: 54
Joined: Sun Oct 09, 2005 6:53 pm

Post by Paco »

CyberBill wrote:You probably need to change some stuff in your makefile to allow for C++ code, too.
At worst a LIBS = -lstdc++, probably needed for STL, new / delete and abstract methods.
Paco
Post Reply