From mboxrd@z Thu Jan 1 00:00:00 1970 From: To: Jayakrishnan J Cc: "Gcc-Help (E-mail)" Subject: Re: Compiling legacy code Date: Sat, 01 Apr 2000 00:00:00 -0000 Message-ID: References: <892CE977BB4FD31194EE00A0C9F2733975E231@BLRK001A> X-SW-Source: 2000-q1/msg00225.html Message-ID: <20000401000000.rbb3Ke9mSWxMwxQwq4vrg4hAJnPBELHdfWkfHf_BAYI@z> On Tue, 8 Feb 2000, Jayakrishnan J wrote: > Hi, > I have some C++ code (from way back) that was earlier compiled on gcc 2.7.2 > Now, we have decided to recompile it using the latest version of gcc. > The C++ code uses some RogueWave classes (6.1.0) > > What are the necessary changes I need to make so as to be able to > recompile my code with the latest version of gcc. > Well, I don't know all the difficulties you will encounter, but here are few I have come across: Conversions such as: char* => char const* signed char* => char* , unsigned char* => char* , etc signed T* => unsigned T* and its reverse are illegal in gcc 2.95.x . Earlier versions of gcc either generated warnings, or silently permitted them. I don't remember if 2.7.2 accepted k&r style function decls and defs in c++ mode, but g++ 2.95.2 definitely will not. const foo=1; is now illegal; change it to 'const int foo;' . I think there have also been some changes to declaring friends of templated classes. I don't remember how to do it under 2.7.2, but 2.95.2 accepts the following: template class A; template class B; template class Foo { public: //A typical binary friend operator: friend bool operator==<>(Foo const& ,Foo const& ); //Making *all* instances of template class A friends. template friend class A; //Making *only* B a friend. friend class B ; }; See http://gcc.gnu.org/gcc-2.95/caveats.html for other possible difficulties. You may be able to improve the design and or readablity of the old code due to the fact that 2.95.2 has much better support for many c++ features, especially templates. See http://gcc.gnu.org/gcc-2.95/c++features.html for details. (Be aware that gcc 2.95.2 may be ahead of some older compilers you may need to keep supporting.) If you have some code you *cannot* convert, try -fpermissive on it; this will make g++ accept lots of now obsolete constructs. I have friends who needed -fpermissive to make X apps written in C++ compile on Solaris (which has very old X headers appearently).