[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

gcc vs. g++: really strange behaviour

Hello list,

I tried to investigate the gftp crash problem and ran into the
following, very strange behaviour. Consider this very little snippet:

#define __USE_XOPEN // this is superfluous, but the same occurs without
this define!
#include <stdlib.h>
#ifdef __USE_XOPEN
#error bla

#include <stdio.h>

int main(int argc, char** argv)
	printf("%s\n", ptsname(0));
	return 0;

Don't complain about the code's not doing anything sensible - it's just
a test. Now if I try to compile that:
steini@telesto:~/coding/tests$ g++ -o test test.c -g -Wall
test.c:3:2: #error bla
Ok, that's what's obvious. BUT:
steini@telesto:~/coding/tests$ gcc -o test test.c -g -Wall
test.c: In function `main':
test.c:10: warning: implicit declaration of function `ptsname'
test.c:10: warning: format argument is not a pointer (arg 2)
huh? Now why is that? __USE_XOPEN not defined anymore (which in turn
kicks out ptsname declaration)? Can anyone reproduce this behaviour? gcc
version used is "Debian 1:3.3.4-7".

Sebastian Steinlechner

Reply to: