Compiler doesn't see exception as declared
I have almost identical code in two programs. The only major difference I can think of is that the one that works has everything defined in the header file. The code that fails is included below. I have tried several things to get g++ to see the exceptions as declared. I've been using KDevelop alpha to do some of this. one thing it's producing for me is the autotools output such as Make, ./configure, etc. That *may* be where the problem lies, but I tend to think otherwise. The problem is in the last block of code below. If i remove the qotes from the other exception, I get the same problem with that. If anybody has a clue, I'd sure appreciate some guidance. Here's the compile command, and error message: make[2]: Entering directory `/home/hattons/code/globalsymmetry/kgdev/src' if g++ -DHAVE_CONFIG_H -I. -I. -I.. -I/opt/kde3/include -I/usr/lib/qt3/include -I/usr/X11R6/include -DQT_THREAD_SUPPORT -D_REENTRANT -Wnon-virtual-dtor -Wno-long-long -Wundef -Wall -pedantic -W -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -Wchar-subscripts -O2 -lxerces-c -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common -MT domsupport.o -MD -MP -MF ".deps/domsupport.Tpo" \ -c -o domsupport.o `test -f 'domsupport.cpp' || echo './'`domsupport.cpp; \ then mv ".deps/domsupport.Tpo" ".deps/domsupport.Po"; \ else rm -f ".deps/domsupport.Tpo"; exit 1; \ fi domsupport.cpp: In member function `xercesc_2_3::DOMWriter* DomSupport::makeNewWriter()': domsupport.cpp:55: error: `e' undeclared (first use this function) domsupport.cpp:55: error: (Each undeclared identifier is reported only once for each function it appears in.) make[2]: *** [domsupport.o] Error 1 make[2]: Leaving directory `/home/hattons/code/globalsymmetry/kgdev/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/hattons/code/globalsymmetry/kgdev' make: *** [all] Error 2 /*************************************************************************** * Copyright (C) 2003 by Steven T. Hatton * * hattons@globalsymmetry.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #ifndef DOMSUPPORT_H #define DOMSUPPORT_H /** @author Steven T. Hatton */ #include <xercesc/util/PlatformUtils.hpp> #include <xercesc/dom/DOM.hpp> #include <xercesc/dom/DOMImplementation.hpp> #include <xercesc/dom/DOMImplementationLS.hpp> #include <xercesc/dom/DOMWriter.hpp> #include <xercesc/framework/StdOutFormatTarget.hpp> #include <xercesc/framework/LocalFileFormatTarget.hpp> #include <xercesc/parsers/XercesDOMParser.hpp> #include <xercesc/util/XMLUni.hpp> #include <xercesc/util/XMLException.hpp> #include <iostream> #include <string> #include "xstr.h" using std::string; using std::cerr; using std::endl; using xercesc::DOMDocument; using xercesc::DOMImplementation; using xercesc::DOMImplementationLS; using xercesc::DOMWriter; using xercesc::XMLString; using xercesc::DOMImplementationRegistry; using xercesc::XMLFormatTarget; using xercesc::StdOutFormatTarget; class DomSupport{ public: DomSupport(); DOMDocument * makeNewDocument(char * const rootTagName="rootElement"); DOMWriter * makeNewWriter(); virtual int initialize(); virtual ~DomSupport(); private: DOMImplementation* impl; }; #endif /*************************************************************************** * Copyright (C) 2003 by Steven T. Hatton * * hattons@globalsymmetry.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #include "domsupport.h" DomSupport::DomSupport() { } DomSupport::~DomSupport(){} int DomSupport::initialize(){ if(!this->impl){ try { this->impl = DOMImplementationRegistry::getDOMImplementation(X("Core")); //XMLPlatformUtils::Initialize(); } catch(const XMLException& toCatch) { char *pMsg = XMLString::transcode(X("toCatch.getMessage()")); std::cerr << "Error during Xerces-c Initialization.\n" << " Exception message:" << pMsg; XMLString::release(&pMsg); return 1; } } return 0; } DOMDocument * DomSupport::makeNewDocument(char * const rootTagName){ DOMDocument* doc = impl->createDocument(0, X(rootTagName), 0); return doc; } DOMWriter * DomSupport::makeNewWriter(){ XMLFormatTarget *myFormTarget; myFormTarget = new StdOutFormatTarget(); DOMWriter *writer; try { writer = ((DOMImplementationLS*)impl)->createDOMWriter(); writer->setFeature(X("format-pretty-print"),true); } catch ( XMLException& e ) { cerr << "An error occurred during creation of output transcoder. Msg is:" << endl << e.getMessage() << endl; } return writer; }
On Monday 07 July 2003 04:08 am, Steven T. Hatton wrote: I took all the code out of the kdevelop environment and took out all the KDE specific stuff. I then hacked the /usr/lib/qt3/mkspecs/linux-g++/qmake.conf to add the "-lxerces-c" to the QMAKE_LIBS variable and everything works. There was a problem with what I sent. See below. [snip]
/ #ifndef DOMSUPPORT_H #define DOMSUPPORT_H
#include <xercesc/util/PlatformUtils.hpp> [...]
This would not have worked because I don't have the correct "using xercesc::XMLException" statement. But I had attemted it with that, as well as with "using namespace xercesc" which didn't work either.
using xercesc::DOMDocument; using xercesc::DOMImplementation; using xercesc::DOMImplementationLS; using xercesc::DOMWriter; using xercesc::XMLString; using xercesc::DOMImplementationRegistry; using xercesc::XMLFormatTarget; using xercesc::StdOutFormatTarget;
steven
participants (1)
-
Steven T. Hatton