Subject: Re: stdio glitch
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: James Chacon <>
List: tech-userlevel
Date: 07/19/2000 19:40:10
I don't have my standard handy but I believe ANSI/ISO allows most of the 
standard library functions to be wrappered as macro's like this for speeds
sake, but if you want the real funtion you'd add:

#undef ferror

after the #include to make sure the real function (with proper protyping
support) was brought into scope. i.e. the whole getc/putc macro sets.


>Is this allowed?
>	% cat foo.c
>	#include <stdio.h>
>	int foo(void *fvp)
>	{ return(ferror(fvp));
>	}
>	% cc -c foo.c
>	foo.c: In function `foo':
>	"foo.c", line 3: warning: dereferencing `void *' pointer
>	"foo.c", line 3: request for member `_flags' in something not a structure or union
>	% 
>ferror isn't *documented* as being non-function-like[%], and if it were
>a real function that would work fine (and indeed s/ferror/(ferror)/
>makes the complaint go away).
>[%] At least not unless you notice, follow, and carefully read the
>stdio(3) SEE ALSO.
>Yet just adding a cast to ferror()'s definition isn't right either;
>that allows too much instead of too little latitude.
>Thoughts?  Should ferror be an inline function, maybe?  Or am I being
>unreasonable in expecting stdio "functions" to act like functions?
>					der Mouse
>		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B