Hello
I am confused with an error saying.

Error 1 error C2664: 'const char *TiXmlElement::Attribute(const char *) const' : cannot convert parameter 1 from 'char *(__cdecl *)(void)' to 'const char *' c:\GameProject\TheGameProject\ContentManager\src\NodeWater.cpp 38

I have a method that returns a const char* as follows

class XMLNodeNames
{
public:
   static struct NODES {
     const static char* NODE_WATER_ATTR_ENABLE() 
     { 
         return "enable";
      }
   }
};

I am using this return value as follows

void NodeWater::processNode(TiXmlElement *element)
{
   element->Attribute (XMLNodeNames::NODES::NODE_WATER_ATTR_ENABLE);
...
}

This is the element element->Attribute definition

const char* Attribute( const char* name ) const;

But it gives me this

error C2664: cannot convert parameter 1 from 'char *(__cdecl *)(void)' to 'const char *'

error

Could you please help me with find the answer?
Thank you

NODE_WATER_ATTR_ENABLE is a function and Attrribute() wants a char*. Try this: element->Attribute (XMLNodeNames::NODES::NODE_WATER_ATTR_ENABLE());

NODE_WATER_ATTR_ENABLE is a function and Attrribute() wants a char*. Try this: element->Attribute (XMLNodeNames::NODES::NODE_WATER_ATTR_ENABLE());

ehhhhhk.
wasted more than a day to find the answer.
Thank you

But could you please tell me what does mean by

char *(__cdecl *)(void)

Bit difficult to find a meaning using google search because of these characters __

Thank you again

That is pointer to a function that returns char*. __cdecl is a calling convention, which is a method used by compilers to pass parameters on the stack and clean up the stack when the runction returns to its caller.

Thank you very much for the explanation. It really helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.