From: Scott D. F. <sd...@ms...> - 2005-09-12 13:43:34
|
Hi Jonathan, I know what the problem is. First of all, here is the error message of interest: g++ -DHAVE_CONFIG_H -I. -I. -I.. -I. -I.. -g -O2 -MT driver.lo -MD -MP -MF .deps/driver.Tpo -c driver.cc -DPIC -o .libs/driver.o In file included from /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/strstream:51, from driver.cc:47: /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_algobase.h: In function `void std::swap(_Tp&, _Tp&) [with _Tp = std::auto_ptr<Opencxx::MetacompilerConfiguration::IteratorIface>]': ../opencxx/MetacompilerConfiguration.h:50: instantiated from here /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_algobase.h:132: error: passing `const std::auto_ptr<Opencxx::MetacompilerConfiguration::IteratorIface>' as `this' argument of `std::auto_ptr<_Tp>::operator std::auto_ptr_ref<_Tp1>() [with _Tp1 = Opencxx::MetacompilerConfiguration::IteratorIface, _Tp = Opencxx::MetacompilerConfiguration::IteratorIface]' discards qualifiers The problem is that in gcc 3.4.x std::auto_ptrs can't be swapped with std::swap. I assume this is a bug in the STL, and not a feature. The reason for the problem is that std::swap has a const tmp variable; i.e. (from bits/stl_algobase.h): template<typename _Tp> inline void swap(_Tp& __a, _Tp& __b) { // concept requirements __glibcxx_function_requires(_SGIAssignableConcept<_Tp>) const _Tp __tmp = __a; // <---THIS CAUSES std::auto_ptr PROBLEMS __a = __b; __b = __tmp; } And std::auto_ptr's auto_ptr_ref operator, which is called in the const line above, is a non-const method; i.e. (from memory.h): template<typename _Tp> class auto_ptr { ... template<typename _Tp1> operator auto_ptr_ref<_Tp1>() throw() { return auto_ptr_ref<_Tp1>(this->release()); } ... My solution to the problem was add my own swap function to the OpenC++ code, and use it to swap std::auto_ptrs. To accomplish this, I edited the MetacompilerConfiguration.h file in the OpenC++ source. I added this function definition near the top of the file just under "class ErrorLog": template<class T> inline void MYswap(std::auto_ptr<T>& a, std::auto_ptr<T>& b) { std::auto_ptr<T> c = a; a = b; b = c; } Next (in the same file), I changed class MetacompilerConfiguration::Iterator (found in the public section of class MetacompilerConfiguration), so that its operator= went from: Iterator& operator=(Iterator iter) { std::swap(impl_, iter.impl_); return *this; } To: Iterator& operator=(Iterator iter) { MYswap(impl_, iter.impl_); return *this; } And this solved the problem for me, and I expect it will for you as well. Now, I must warn you that there is another problem you will encounter with OpenC++ once you have built it. There is a mistake in the grammar that OpenC++'s parser expects. Prior to GCC 3.4, this was never a problem, but since GCC 3.4, the STL library uses the syntax that the broken grammar doesn't accept. In particular OpenC++ expects template declarations to look like this: template<typename T>... With an identifier like "T" following typename, but in fact the following is legal C++: template<typename>... This causes occ to issue errors whenever it parses the GCC library files that include the latter syntax (e.g., bits/cpp_type_traits.h). I fixed the problem by changing the Parser::rTempArgDeclaration member function definition in parser/Parser.cc. I changed this line (roughly the third line in the function): if(t0 == CLASS && lex->LookAhead(1) == Identifier){ To this: if(t0 == CLASS && !(lex->LookAhead(1) == Identifier)){ lex->GetToken(tk1); decl = PtreeUtil::List(new Leaf(tk1)); } else if(t0 == CLASS && lex->LookAhead(1) == Identifier){ I am not positive that my Ptree representation for the template argument declaration (temp.arg.declaration) is exactly what the OpenC++ maintainers would want, but it seemed to make sense to me. Anyway, I hope these fixes help you get OpenC++ running. I've been using it for a couple of years, and it's really a lovely tool. Cheers, Scott PS: There is one other fix that you will probably want to apply, found in: http://sourceforge.net/mailarchive/message.php?msg_id=9785370 Jonathan Gdalevich wrote: > Dear OpenC++ users, > > I am trying to make the latest version of OpenC++ (2.8) in Cygwin with > gcc (3.4.4) and all latest updates and getting an error during make. > Attached are my configure and make log files along with the Makefile. > > Sincerely, > > |