6 Replies - 476 Views - Last Post: 05 February 2019 - 10:02 PM Rate Topic: -----

#1 seggaran5   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-October 09

Unix C++ Compiler Error

Posted 30 January 2019 - 05:39 PM

im trying to compile a c++program in unix enviroment at HPUX box via c++ Compiler, but im hit with below error.
Im not sure where it goes wrong as using the same file we are able to compile in Sun Solaris Enviroment

Error:
[89] % gmake -f xml.mk
g++ -g -D__USE_STD_IOSTREAM -DBSD -DOSFDEC10 -DAXPOSF -DAXP30 -ansi -I/usr/local/include -I/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/include -I/usr/local/include/g++-3 -I/export2/home/oracle/client/product/11.2.0/rdbms/demo -I/export2/home/oracle/client/product/11.2.0/rdbms/public -I/export2/mes/FASTech/SDT/include -I./ -I../../../../export/cxx/include -c action_store.cpp -o action_store.o
In file included from action_store.h:33,
from action_store.cpp:30:
tinyxml.h: In member function 'int TiXmlElement::AppendChild(const std::string&, const T&)':
tinyxml.h:1163: error: no matching function for call to 'TiXmlElement::InsertEndChild(TiXmlText&)'
tinyxml.h:587: note: candidates are: TiXmlNode* TiXmlNode::InsertEndChild(const TiXmlNode&)
gmake: *** [../../bld_default.mk:105: action_store.o] Error 1

Code
#ifdef TIXML_USE_STL
template < typename T >
int AppendChild( const std::string& name, const T& value ) 
{ 
std::ostringstream	ss;	
ss << value; 
std::string valueStr = ss.str(); 

TiXmlText textNode(valueStr.c_str()); 
TiXmlElement childElement(name.c_str()); 

childElement.InsertEndChild(textNode); 
this->InsertEndChild(childElement);

return TIXML_SUCCESS; 
}
#endif 
:code:

Note:Im using a standard tinyxml.h

This post has been edited by modi123_1: 30 January 2019 - 06:15 PM
Reason for edit:: In the future please use the [code] tag button in the editor


Is This A Good Question/Topic? 0
  • +

Replies To: Unix C++ Compiler Error

#2 jimblumberg   User is online

  • member icon

Reputation: 5678
  • View blog
  • Posts: 17,444
  • Joined: 25-December 09

Re: Unix C++ Compiler Error

Posted 30 January 2019 - 07:24 PM

It looks like TiXmlElement::InsertEndChild() expects a const TiXmlNode reference not a TiXmlText reference.

Quote

Note:Im using a standard tinyxml.h

What does this mean? That header is not a standard C or C++ header.

Jim
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6767
  • View blog
  • Posts: 23,073
  • Joined: 05-May 12

Re: Unix C++ Compiler Error

Posted 30 January 2019 - 07:55 PM

Check to see if you have other errors or warning prior to that error. According to this documentation, TiXmlText derives from TiXmlNode.

Update: On re-reading the error messages above, it looks like this is the first error, and there are no warnings before it. On the other hand, it doesn't look like the compiler flag to produces warnings is enabled, either.

I suggest checking to see what version of TinyXML you are using and see if the version on that platform matches the version on the other platforms where the builds succeed.
Was This Post Helpful? 0
  • +
  • -

#4 Salem_c   User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 2310
  • View blog
  • Posts: 4,418
  • Joined: 30-May 10

Re: Unix C++ Compiler Error

Posted 30 January 2019 - 09:11 PM

Cross-posted here -> http://www.cplusplus...general/249243/
With basically the same answers.
Was This Post Helpful? 1
  • +
  • -

#5 kyungsoo   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-February 19

Re: Unix C++ Compiler Error

Posted 05 February 2019 - 09:11 PM

View PostSalem_c, on 30 January 2019 - 09:11 PM, said:

Cross-posted here -> http://www.cplusplus...general/249243/
With basically the same answers.


but both TiXmlElement and TiXmlText inherits TiXmlNode.

class TiXmlElement : public TiXmlNode


class TiXmlText : public TiXmlNode
{
	friend class TiXmlElement; 


Here's the problematic code in tinyxml.h:

#ifdef TIXML_USE_STL
	template < typename T > int AppendChild( const std::string& name,  const T& value ) 
	{ 		
		std::ostringstream	ss;	
		ss << value; 
		std::string valueStr = ss.str(); 
		
		TiXmlText textNode(valueStr.c_str()) ;  
		TiXmlElement childElement(name.c_str()); 
		
		childElement.InsertEndChild(textNode); 
		this->InsertEndChild(childElement); 
		
		return TIXML_SUCCESS; 
	}
	#endif 


InsertEndChild function in tinyxml.cpp:

TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis )
{
	if ( addThis.Type() == TiXmlNode::DOCUMENT )
	{
		if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
		return 0;
	}
	TiXmlNode* node = addThis.Clone();
	if ( !node )
		return 0;

	return LinkEndChild( node );
}


How to solve this error?
Was This Post Helpful? 0
  • +
  • -

#6 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6767
  • View blog
  • Posts: 23,073
  • Joined: 05-May 12

Re: Unix C++ Compiler Error

Posted 05 February 2019 - 09:40 PM

Are those bits of code from the copy of TinyXml on that machine which is failing? Or are you looking at a different copy from somewhere else?
Was This Post Helpful? 0
  • +
  • -

#7 kyungsoo   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-February 19

Re: Unix C++ Compiler Error

Posted 05 February 2019 - 10:02 PM

View PostSkydiver, on 05 February 2019 - 09:40 PM, said:

Are those bits of code from the copy of TinyXml on that machine which is failing? Or are you looking at a different copy from somewhere else?


yes those bits of code are from the copy of TinyXml on the machine which is failing. Attached is the full source code.

Attached File  tinyxml.txt (66.11K)
Number of downloads: 6
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1