[parisc-linux] The printf fiasco
Matthew Wilcox
matthew@wil.cx
Mon, 26 Mar 2001 01:02:39 +0100
On Mon, Mar 26, 2001 at 12:55:38AM +0100, Alan Cox wrote:
> Actually you cant take the address. Instead your
>
> (void *)printf
>
> generates
> (void *)fprintf
>
> and your program core dumps mysteriously at run time
No it doesn't.
# cat ./def-test.c
#include <stdio.h>
int main(void)
{
void *a = (void *)printf;
void *b = (void *)fprintf;
#undef printf
void *c = (void *)printf;
printf("a = %p, b = %p, c = %p\n", a, b, c);
return 0;
}
# gcc -O2 -Wall -W def-test.c -o def-test
# gcc --version
3.0
# ./def-test
a = 0x26f2, b = 0x271a, c = 0x26f2
that's because
# if __GNUC_PREREQ (2,97)
# define printf(fmt, args...) fprintf (stdout, fmt, ##args)
# endif
doesn't match printf, but only printf(...)
--
Revolutions do not require corporate support.