Peter Keenan wrote:
however the program compiles and gives
SizeOf( LongReal) = 8 sin( 1.2345) = 0.943983323944511099057308456395 sin( 1.2345) = 0.943983323944511099057308456395 = 0.943983323944511099057308456395 sin( 1.2345) = 0.943983323944511099057308456395 = 0.943983323944511099057308456395 = 0.943983323944511099057308456395
Ah, thanks but I forgot to ask passing -mlong-double-128 as a command-line option. Without that option, the output of gpc and gcc is correct on powerpc-apple-darwin.
/home/pkeenan/local/bin/../lib/gcc-lib/powerpc-ibm- aix5.2.0.0/3.3.4/../../../../powerpc-ibm-aix5.2.0.0/bin/ld: warning: powerpc:601 architecture of input file `/home/pkeenan/local/bin/../lib/gcc-lib/powerpc-ibm- aix5.2.0.0/3.3.4/libgcc_eh.a(unwind-dw2-fde.o)' is incompatible with rs6000:6000 output /tmp//cch9Ygvn.o(.pr+0x94):longreal.c: undefined reference to `.sin' collect2: ld returned 1 exit status
I only know that IBM uses the POWER instruction set, where Apple uses the PowerPC instruction set <http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/RS_002f6000-and-PowerPC- Options.html>. However, the message speaks about "architecture of input file" not about instruction sets. Could it make a difference what linker you are using ? (I am guessing, I don't know AIX at all).
There have been threads about gpc on AIX ( e.g. http://www.gnu-pascal.de/crystal/gpc/en/mail10545.html).
the native AIX cc compiler gives ld: 0711-317 ERROR: Undefined symbol: .sin
The sin is not important in the test, here is another test:
program LongReals; var R: LongReal; begin R:= 1.234567890123456789012345678900; WriteLn( 'SizeOf( LongReal) = ', SizeOf( LongReal)); WriteLn( 'R = ', R:1:30); WriteLn( 'R = ', R:1:30, ' = ', R:1:30); WriteLn( 'R = ', R:1:30, ' = ', R:1:30, ' = ', R:1:30); end.
#include <stdio.h>
int main( void ) { long double R; R = 1.234567890123456789012345678900; printf( "sizeof( long double) = %d\n", sizeof( long double)); printf( "R = %1.30Lf = %1.30Lf\n", R, R); return 0; }
The results are remarkable:
For gcc-3.4.3:
[G5:gpc/testgpc/adriaan] adriaan% gcc longreals5.c -mlong-double-128 [G5:gpc/testgpc/adriaan] adriaan% ./a.out sizeof( long double) = 16 R = 1.234567890123456690432135474111 = 0.000000000000000000000000000000
For gcc version 4.0.0 20050213 (experimental):
[G5:gpc/testgpc/adriaan] adriaan% gcc4 longreals5.c -mlong-double-128 [G5:gpc/testgpc/adriaan] adriaan% ./a.out sizeof( long double) = 16 R = 1.234567890123456690432135474111 = 0.000000000000000000000000000000
For gpc-20041218 with gcc-3.4.3:
[G5:gpc/testgpc/adriaan] adriaan% gpc longreals5.pas -mlong-double-128 [G5:gpc/testgpc/adriaan] adriaan% ./a.out SizeOf( LongReal) = 16 R = 1 R = 1 = 1.234567890123456690432135474111419171094894409180 Segmentation fault
with backtrace:
Exception: EXC_BAD_ACCESS (0x0001) Codes: KERN_INVALID_ADDRESS (0x0001) at 0x8dccc770
Thread 0 Crashed: 0 a.out 0x0000ea9c _p_Write_Real + 0x3d4 (files.pas:2747) 1 a.out 0x0000e7b4 _p_Write_Real + 0xec (files.pas:2653) 2 a.out 0x00002bac _p__M0_main_program + 0x31c (crt.c:300) 3 a.out 0x00002ca4 main + 0x50 (crt.c:300) 4 a.out 0x000024c8 _start + 0x188 (crt.c:267) 5 dyld 0x8fe1a558 _dyld_start + 0x64
Regards,
Adriaan van Os