🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Dean Schulze Tue, 08 Sep 1992 19:04
(none)
#1087
Author: Dean Schulze
Date: Tue, 08 Sep 1992 19:04
82 lines
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads