How to handle error compiling GCC 4.7.0 using GCC 6.2.1

I agree that using a newer gcc is often not a good option. I had to write a new program for an embedded ARM v4 system running Pengutronix stuck at a 2.6 kernel and an old glibc. Therefore I had to compile the old toolchain on my system.

Often newer GCC versions find errors in the source code, that have been present there for quite some time. Instead of turning the error checking off, I advise to fix the source code instead.

According to the error log the function declaration and the function header do not match for

const char * libc_name_p (const char *, unsigned int);

in file cfns.h included in except.c

Edit cfns.h and change the function declaration

#ifdef __GNUC__
__inline
#endif
const char * libc_name_p (const char *, unsigned int);

to

#ifdef __GNUC__
__inline
#ifdef __GNUC_STDC_INLINE__
__attribute__ ((__gnu_inline__))
#endif
#endif
const char * libc_name_p (const char *, unsigned int);

Then compilation should work.


You'll probably end up spending an awful lot of time getting GCC 4.7 built on your current system, and in the end you still won't be sure of the result: your school's computers' version of GCC may include distribution patches or even local changes which your version won't have.

I would suggest instead that you run the distribution your school is using in a VM. Your school is using RHEL, and you can too: you can get a no-cost developer subscription from Red Hat Developers; once you've got your subscription, you can download ISOs of any still-supported version of RHEL, so you should be able to install the same version as used on the school computers.

In any case since this is for grading purposes you should always check your code on the school computers before submitting it!