"功能已经有了身体"

bal*_*oka 5 visual-c++

这是什么意思?

1>c:\users\vitali\documents\visual studio 2010\projects\salam\tools.cpp(107): error C2084: function 'bool readXMLInteger(xmlNodePtr,const char *,int &)' already has a body
1>c:\users\vitali\documents\visual studio 2010\projects\salam\tools.h(52) : see previous definition of 'readXMLInteger'
Run Code Online (Sandbox Code Playgroud)

tools.cpp(107):

bool readXMLInteger(xmlNodePtr node, const char* tag, int32_t& value)
{
    char* nodeValue = (char*)xmlGetProp(node, (xmlChar*)tag);
    if(nodeValue)
    {
        value = atoi(nodeValue);
        xmlFreeXOXL(nodeValue);
        return true;
    }

    return false;
}
Run Code Online (Sandbox Code Playgroud)

的Tools.h(52)

bool readXMLInteger(xmlNodePtr node, const char* tag, int& value);
Run Code Online (Sandbox Code Playgroud)

小智 10

您是否在原始头文件中使用了包含警戒?

例如:

#ifndef _TOOLS_H_
#define _TOOLS_H_

... your header body is here ...

#endif
Run Code Online (Sandbox Code Playgroud)

这阻止了在包含它的每个cpp中重新定义.


Cha*_*tin 7

这意味着在某些时候您的实际代码被重新读入编译流,因此似乎有两次尝试定义(而不是声明)该函数.

怀疑你设置预处理器语句的方式.