This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: stdio.h: broken standard compliance.


On Sun, 09 Oct 2011 11:08:58 -0700, Kaz Kylheku <kaz@kylheku.com>
wrote:
> reason, I cannot get a warning about fileno from this test case if
> I add a reference to it. I will try to produce a minimal repro test
> case for that.

In my real program I have -Wall, and I'm not taking the function
pointers.

With -Wall we get warnings about implicit declarations.

So, here is a better test case which shows that these identifiers are
not declared when they should be. Of course the two errors occur
without -Wall.

$ cat posix-ansi.c
#include <stdio.h>

void foo(void)
{
  int (*f1)(FILE *) = fileno;
  int (*f2)(FILE *) = pclose;
}

int main(void)
{
  int x = fileno(stdin);
  pclose(NULL);
  return 0;
}

$ gcc -Wall -ansi -D_POSIX_C_SOURCE=2 posix-ansi.c
posix-ansi.c: In function 'foo':
posix-ansi.c:5:23: error: 'fileno' undeclared (first use in this
function)
posix-ansi.c:5:23: note: each undeclared identifier is reported only
once for ea
ch function it appears in
posix-ansi.c:6:23: error: 'pclose' undeclared (first use in this
function)
posix-ansi.c:6:9: warning: unused variable 'f2'
posix-ansi.c:5:9: warning: unused variable 'f1'
posix-ansi.c: In function 'main':
posix-ansi.c:11:3: warning: implicit declaration of function 'fileno'
posix-ansi.c:12:3: warning: implicit declaration of function 'pclose'
posix-ansi.c:11:7: warning: unused variable 'x'


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]