Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix error: unknown type name ‘namespace’

Tags:

c++

#ifndef UNO_ACTION_ 
#define UNO_ACTION_
namespace Uno
{
namespace Game
{
    class Game;
}
} // namespace

namespace Uno
{
namespace Action
{
using ::Uno::Game::Game;

class Action
{
public:
    virtual bool isDisposeable() = 0;
    virtual void takeAction(Game* game) = 0;
    virtual ~Action() {}
};

}
}
#endif

I compile these code on ubuntu 12.04 and it returns to set of error:

action.h:4:1: error: unknown type name ‘namespace’
action.h:4:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
action.h:8:1: error: unknown type name ‘namespace’
action.h:8:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token

How do I solve these errors?

like image 933
Daniel Avatar asked Nov 28 '12 09:11

Daniel


1 Answers

It sounds like you're trying to compile your C++ code with a C compiler. Try using g++ instead of gcc and giving your file a C++ extension such as .cpp (rather than .c).

like image 106
NPE Avatar answered Sep 17 '22 02:09

NPE