Compiling legacy code
llewelly@198.dsl.xmission.com
llewelly@198.dsl.xmission.com
Mon Feb 7 22:27:00 GMT 2000
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<typename T> class A;
template<typename T> class B;
template<typename TT>
class Foo
{
public:
//A typical binary friend operator:
friend bool operator==<>(Foo const& ,Foo const& );
//Making *all* instances of template class A friends.
template<typename X> friend class A;
//Making *only* B<TT> a friend.
friend class B<TT> ;
};
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).
More information about the Gcc-help
mailing list