如何修复错误:未知的类型名称'namespace' [英] how to fix error: unknown type name ‘namespace’
本文介绍了如何修复错误:未知的类型名称'namespace'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#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
在ubutun 12.04上编译这些代码,并返回错误集:
I compile these code on ubutun 12.04 and it return 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
我不知道如何解决这些错误。
I don't know how to solve these errors.
推荐答案
听起来你正试图用C编译器编译你的C ++代码。尝试使用 g ++
而不是 gcc
,并为您的文件提供C ++扩展,例如 .cpp
(而不是 .c
)。
It sounds like you're trying to compile your C++ code with a C compiler. Trying using g++
instead of gcc
and giving your file a C++ extension such as .cpp
(rather than .c
).
这篇关于如何修复错误:未知的类型名称'namespace'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文