need help on compile error on invalid conversion

Dear c/g++ experts:

at stage of make, while I install/build pathan1.2r2
I meet error about invalid conversion from 'XMLCH*' to 'short int'
and initializing argument 2 of 'someException'

as following on my g++4.5.2 linux2.6.38-10

--------------------------------------------------------------------------

g++ -c -DUNIX -Wall -ftemplate-depth-50 -O2 -I/home/eric/cppcookbook/ch14/download/libpathan-1.2/src/patches/Xerces2_1_0/src -I/usr/src -I/home/eric/cppcookbook/ch14/download/libpathan-1.2/src XPathEvaluatorImpl.cpp -fPIC -DPIC -o /home/eric/cppcookbook/ch14/download/libpathan-1.2/objs/.libs/XPathEvaluatorImpl.o
XPathEvaluatorImpl.cpp: In member function 'virtual XPathExpression* XPathEvaluatorImpl::createExpression(const XMLCh*, const XPathNSResolver*) const':
XPathEvaluatorImpl.cpp:93:190: error: invalid conversion from 'XMLCh*' to 'short int'
XPathEvaluatorImpl.cpp:93:190: error: initializing argument 2 of 'xercesc_3_1::DOMException::DOMException(short int, short int, xercesc_3_1::MemoryManager*)'
make[1]: *** [/home/eric/cppcookbook/ch14/download/libpathan-1.2/objs/XPathEvaluatorImpl.lo] Error 1
make[1]: Leaving directory `/home/eric/cppcookbook/ch14/download/libpathan-1.2/src/interface'
make: *** [subdirs] Error 2
---------------------------------------------------
XPathEvaluatorImpl.cpp
------------------------------------------------------------------
1
2
3
      throw XERCES_CPP_NAMESPACE_QUALIFIER DOMException(XERCES_CPP_NAMESPACE_QUALIFIER DOMException::NAMESPACE_ERR, XERCES_CPP_NAMESPACE_QUALIFIER             // This is line 93
XMLString::transcode(e.getError().c_str()));

-------------------------------------------------------------
DOMException.hpp // about its constructor
------------------------
1
2
3
4
5
6
7
8
9
10
    /**
      * Constructor which takes an error code and an optional message code.
      *
      * @param code           The error code which indicates the exception
      * @param messageCode    The string containing the error message
      * @param memoryManager  The memory manager used to (de)allocate memory
      */
    DOMException(short code,
                 short messageCode = 0,
                 MemoryManager* const  memoryManager = XMLPlatformUtils::fgMemoryManager);

Please help and thanks a lot in advance, Eric
Last edited on
XMLString::transcode(e.getError().c_str()) sounds like something that would return a XMLCH*.. Though it might be the first argument too. And what is XERCES_CPP_NAMESPACE_QUALIFIER ? You don't provide enough information to be sure..
Anyway, if the constructor wants a short int, you can't pass it a pointer. Do you actually want to have that pointer converted to a short, or did you not expect something there return a pointer ?
the most related definition about XERCES_CPP_NAMESPACE_QUALIFIER is
-------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XercesDefs.hpp 527149 2007-04-10 14:56:39Z amassari $
 */

#if !defined(XERCESC_INCLUDE_GUARD_XERCESDEFS_HPP)
#define XERCESC_INCLUDE_GUARD_XERCESDEFS_HPP

// ---------------------------------------------------------------------------
//  The file xerces_hdr_config defines critical configuration information
//	used by the remainder of this file.
//
//	There are two major configuration files:
//		- xerces_autoconf_config.hpp-- Contains defines that are safe for
//									   access through public headers.
//
//		- config.h					-- Contains defines that may conflict
//									   with other packages; should only be
//									   included by Xerces implementation files.
//
//	Both of these files are generated through the autoconf/configure process.
// ---------------------------------------------------------------------------

//
// If this is an autoconf configured build, we include Xerces_autoconf_config.hpp
// Otherwise we include a preconfigured config appropriate for the particular
// platform that the specific makefile should copy over.
//
//  If the next line generates an error then you haven't run ./configure
#include	<xercesc/util/Xerces_autoconf_config.hpp>

// ---------------------------------------------------------------------------
//  Include the Xerces version information; this is kept in a separate file to
//  make modification simple and obvious. Updates to the version header file
// ---------------------------------------------------------------------------
#include    <xercesc/util/XercesVersion.hpp>


// ---------------------------------------------------------------------------
//  Some general typedefs that are defined for internal flexibility.
//
//  Note  that UTF16Ch is fixed at 16 bits, whereas XMLCh floats in size per
//  platform, to whatever is the native wide char format there. UCS4Ch is
//  fixed at 32 bits. The types we defined them in terms of are defined per
//  compiler, using whatever types are the right ones for them to get these
//  16/32 bit sizes.
//
// ---------------------------------------------------------------------------
typedef unsigned char       XMLByte;
typedef XMLUInt16           UTF16Ch;
typedef XMLUInt32           UCS4Ch;


// ---------------------------------------------------------------------------
//  Handle boolean. If the platform can handle booleans itself, then we
//  map our boolean type to the native type. Otherwise we create a default
//  one as an int and define const values for true and false.
//
//  This flag will be set in the per-development environment stuff above.
// ---------------------------------------------------------------------------
#if defined(XERCES_NO_NATIVE_BOOL)
  #ifndef bool
    typedef int     bool;
  #endif
  #ifndef true
    #define  true     1
  #endif
  #ifndef false
    #define false 0
  #endif
#endif

// ---------------------------------------------------------------------------
//  According to whether the compiler suports L"" type strings, we define
//  the XMLStrL() macro one way or another.
// ---------------------------------------------------------------------------
#if defined(XERCES_LSTRSUPPORT)
#define XMLStrL(str)  L##str
#else
#define XMLStrL(str)  str
#endif


// ---------------------------------------------------------------------------
// Define namespace symbols if the compiler supports it.
// ---------------------------------------------------------------------------
#if defined(XERCES_HAS_CPP_NAMESPACE)
    #define XERCES_CPP_NAMESPACE_BEGIN namespace XERCES_CPP_NAMESPACE {
    #define XERCES_CPP_NAMESPACE_END  }
    #define XERCES_CPP_NAMESPACE_USE using namespace XERCES_CPP_NAMESPACE;
    #define XERCES_CPP_NAMESPACE_QUALIFIER XERCES_CPP_NAMESPACE::

    namespace XERCES_CPP_NAMESPACE { }
    namespace xercesc = XERCES_CPP_NAMESPACE;
#else
    #define XERCES_CPP_NAMESPACE_BEGIN
    #define XERCES_CPP_NAMESPACE_END
    #define XERCES_CPP_NAMESPACE_USE
    #define XERCES_CPP_NAMESPACE_QUALIFIER
#endif

#if defined(XERCES_STD_NAMESPACE)
	#define XERCES_USING_STD(NAME) using std :: NAME;
	#define XERCES_STD_QUALIFIER  std ::
#else
	#define XERCES_USING_STD(NAME)
	#define XERCES_STD_QUALIFIER 
#endif

------------------------------
Please suggest how to modify (which is pointer? and how to make it accept by short int. i.e. static_cast<short int> ?)
Well, this explains that XERCES_CPP_NAMESPACE_QUALIFIER is not the problem.. It says noting about the other two..
I hadn't noticed. It is written that argument two is the problem.
How to fix this depends on what you want this to do.
 
XPathEvaluatorImpl.cpp:93:190: error: initializing argument 2 of 'xercesc_3_1::DOMException::DOMException(short int, short int, xercesc_3_1::MemoryManager*)'


is this you mean my make fail?
can you fix it by modify this XPathEvaluatorImpl.cpp file somewhere related about line 93, as least as possible. since pathan now is not supported but
xerces 3.1 is supported and is newest version , so I don't want to modify it.
If I know very precise what the author of pathan1.2r2 and xercesc3.1, I may fix it by myself. I certainly will. It just need time.
To fix this you could simply erase the second argument (since it has a default value of 0). I'm not familiar with xerces and I fail to find any sense in some of your sentences, so I can't give a better solution.
Thanks your help
this problem is solved
Topic archived. No new replies allowed.