This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
fopen fails on aix
- To: <gcc-help at gcc dot gnu dot org>
- Subject: fopen fails on aix
- From: John v/d Kamp <blade_ at dds dot nl>
- Date: Mon, 5 Mar 2001 15:02:03 +0100 (CET)
Hi,
For my work, I have to port a program from the default cc compiler on AIX
to gcc/g++. But this is not completly going smoothly. The problem I am
facing now is that fopen(...) lets my program exit, with sometimes
different return codes, and no error message whatsoever.
The compiler is g++ 2.95.2
The linker is GNU ld 2.9.1 and seems to use libraries from
/apps/oss/lib/gcc-lib/rs6000-ibm-aix4.2.1.0/2.95.2 and /lib because of
missing (why, I don't know) libraries, like libg.a, libm.a and libc.a (is
this normal?)
simple example of a failing program:
---8<---
#include <stdio.h>
int main(int argc, char *argv[])
{
FILE *f = NULL;
f = fopen(argv[1], "r"); // does not execute corretly
if (!f) { // never reached!
printf("Can't open %s.\n", argv[1]);
return -1;
}
printf("file %s is now open.\n", argv[1]);
fclose(f);
return 0;
}
$ g++ -Wall -g -static -o ftest filetest.cpp
$ ./ftest filetest.cpp
$ echo $?
80
$
--->8---
Anybody knows what's going on?
Thanks for any pointers,
John