C++ 重新定义为另一种符号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12403448/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Redefinition of as a different kind of symbol
提问by nishantkyal
I'm creating a simple C++ header file in my xcode ios project but getting error "Redifinition of 'foo' as a different kind of symbol".
我正在我的 xcode ios 项目中创建一个简单的 C++ 头文件,但收到错误“将‘foo’重新定义为不同类型的符号”。
Here's the code
这是代码
class foo
{
public:
char* getLabel(char* params);
};
回答by SingerOfTheFall
Well, the error message is pretty self-explanatory, foo
is already defined in the same namespace, and you are trying to re-define it.
嗯,错误消息是不言自明的,foo
已经在同一个命名空间中定义了,您正在尝试重新定义它。
The part "as a different kind of symbol" suggests that the existing foo
is something else rather than a class definition. Changing the name will most likely solve your issue. Another way would be to put your definition of foo
into another namespace. And anyway I would not recommend you to name something as foo
in a realproject, no matter how small it is ;)
“作为一种不同类型的符号”部分表明存在foo
是别的东西而不是类定义。更改名称很可能会解决您的问题。另一种方法是将您的定义foo
放入另一个命名空间。反正我不建议你命名的东西作为foo
一个真正的项目,不管它是多么小;)