linux 跨版本问题

1 //redhattest.c
2  #include <stdio.h>
3  int main()
4 {
5 int a=0;
6
7 printf ("this is compiled in Red Hat, %d\n",a);
8
9 return 0;
10 }
11
gcc -o RadHatTest redhattest.c

编译完之后放到centos上运行可以正常运行

Red Hat版本信息
Red Hat Enterprise Linux AS release 3 (Taroon Update 5)
Kernel \r on an \m

Linux version 2.4.21-32.EL (bhcompile@tweety.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-52)) #1 Fri Apr 15 21:17:56 EDT 2005
2.4.21-32.EL
gcc版本信息
gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-52)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

1 //centostest.c
2  #include <stdio.h>
3 int main()
4 {
5 int a=0;
6
7 printf ("this is compiled in Centos, %d\n",a);
8
9 return 0;
10 }
11
gcc -o CentosTest centostest.c
编译完之后放到red hat上运行得到"浮点数例外"的错误信息
centos 版本信息

CentOS release 5.5 (Final)
Kernel \r on an \m

Linux version 2.4.21-32.EL (bhcompile@tweety.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-52)) #1 Fri Apr 15 21:17:56 EDT 2005

2.6.18-194.8.1.el5
gcc版本信息

gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

原文地址:https://www.cnblogs.com/eavn/p/1810369.html