Article View: gnu.gcc.bug
Article #1087(none)
From: Dean Schulze
Date: Tue, 08 Sep 1992 19:04
Date: Tue, 08 Sep 1992 19:04
82 lines
2450 bytes
2450 bytes
Sept. 8, 1992
Hello FSF,
I'm having two problems with GNU C v1.39 running under Sun OS 4.1.1 on a
SPARC system.
The first involves the function ungetc(). Here is a file that
demonstrates the problem. (This code comes from the file
lread.c which is part of the distribution for ATT's fortran to C converter
f2c. lread.c is part of the library libI77.)
#include "stdio.h"
int (*l_ungetc)();
/*
inserting this line allows the code to complile
#define ungetc
*/
#ifdef ungetc
static int
#ifdef KR_headers
un_getc(x,cf) int x; FILE *cf;
#else
un_getc(int x, FILE *cf)
#endif
{ return ungetc(x,cf); }
#else
#define un_getc ungetc
#ifdef KR_headers
extern int ungetc();
#endif
#endif
int AFunction()
{
l_ungetc = un_getc;
return (0);
}
Apparently if ungetc isn't #defined the user is supposed to supply their own.
However, gcc thinks that ungetc is not #defined, so the macro un_getc gets
set to ungetc. (I'm not using KR_headers.)
The compiler generates the following error message:
lread.c: In function s_rsle:
lread.c:584: `ungetc' undeclared (first use this function)
lread.c:584: (Each undeclared identifier is reported only once
lread.c:584: for each function it appears in.)
How is ungetc() implemented in GNU C? I can't find a prototype for it
in any of the header files, but it exists in one of the libraries and other
code that uses it works. I've also tried compiling with the -E switch to
see if ungetc() was implemented as a macro, but it isn't.
I got the code to compile by placing a
#define ungetc
before the
#ifdef ungetc
statement. If ungetc is a library function why isn't there a prototype for
it? If it is "built in" to GNU C why isn't the compiler aware of it when
cpp encounters the
#ifdef ungetc
statement?
The second problem involves the function strtoul(). It doesn't seem to
exist in GNU C v1.39. Does it exist or was it left out of v1.39?
Dean Schulze
schulze@argus.lpl.arizona.edu
Technical Details
Message-ID:
<9209081904.AA29749@asgard.lpl.Arizona.EDU.LPL-West>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!asgard.lpl.arizona.edu!schulzeShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!asgard.lpl.arizona.edu!schulze From: schulze@asgard.lpl.arizona.edu (Dean Schulze) Subject: (none) Message-ID: <9209081904.AA29749@asgard.lpl.Arizona.EDU.LPL-West> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Tue, 8 Sep 1992 19:04:41 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 84