c:\users\vitali\documents\visual studio 2010\projects\salam\tools.cpp(107): error C2084: ...">

"function already has a body"

What does it mean?

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'

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;
}

tools.h (52)

bool readXMLInteger(xmlNodePtr node, const char* tag, int& value);
+5
source share
6 answers

Did you use include guards in the source header file?

For instance:

#ifndef _TOOLS_H_
#define _TOOLS_H_

... your header body is here ...

#endif

This blocks redefinition in each cpp where it is included.

+10
source

This means that at some point your real code is re-read into the compilation stream, so it seems like two attempts to define (as opposed to declaring) a function.

Suspect that you have configured preprocessor instructions.

+7
source

, , .

.cpp, .pch . , , .

+3

, - .

+2

, . .

, , cMyClass() {}, , (, )

, . cMyClass(); .

+1

Also, check if you made a copy of the file (extension .cxx or .cpp) in the same directory. Thus, the function will be defined twice.
I get an error for static functions!

0
source

Source: https://habr.com/ru/post/1791915/


All Articles