JohnWStockwellJr / SeisUnix

The CWP/SU: Seismic Un*x Package - a free open seismic processing, research, and educational software package. Please seek distribution gzipped tar files at https://wiki.Seismic-Unix.org not the Github version.
https://wiki.Seismic-Unix.org
Other
266 stars 123 forks source link

SFIO no_stdio.h compilation failures #154

Open meerfrau opened 1 year ago

meerfrau commented 1 year ago

gcc 12.2

SFIO's fclose.c, getchar.c and probably also scanf.c, vscanf.c and gets.c fail because stdio headers are missing:

fclose.c: In function 'fclose':
fclose.c:20:44: error: 'stdin' undeclared (first use in this function)
   20 |         if((rv = sfclose(sf)) >= 0 && f != stdin && f != stdout && f != stderr)
      |                                            ^~~~~
fclose.c:2:1: note: 'stdin' is defined in header '<stdio.h>'; did you forget to '#include <stdio.h>'?
    1 | #include        "sfstdio.h"
  +++ |+#include <stdio.h>
    2 | 
fclose.c:20:44: note: each undeclared identifier is reported only once for each function it appears in
   20 |         if((rv = sfclose(sf)) >= 0 && f != stdin && f != stdout && f != stderr)
      |                                            ^~~~~
fclose.c:20:58: error: 'stdout' undeclared (first use in this function)
   20 |         if((rv = sfclose(sf)) >= 0 && f != stdin && f != stdout && f != stderr)
      |                                                          ^~~~~~
fclose.c:20:58: note: 'stdout' is defined in header '<stdio.h>'; did you forget to '#include <stdio.h>'?
fclose.c:20:73: error: 'stderr' undeclared (first use in this function)
   20 |         if((rv = sfclose(sf)) >= 0 && f != stdin && f != stdout && f != stderr)
      |                                                                         ^~~~~~
fclose.c:20:73: note: 'stderr' is defined in header '<stdio.h>'; did you forget to '#include <stdio.h>'?
/* While building the compatible stdio interface, we don't want <stdio.h>
** to be included. Fortunately, these files tend to be protected by a single
** macro defined at the top of each file to prevent multiple inclusion.
** This header file defines the same macros here.

Therefore including doesn't improve the situation:

fclose.c: In function 'fclose':
fclose.c:21:44: error: 'stdin' undeclared (first use in this function)
   21 |         if((rv = sfclose(sf)) >= 0 && f != stdin && f != stdout && f != stderr)
      |                                            ^~~~~
fclose.c:3:1: note: 'stdin' is defined in header '<stdio.h>'; did you forget to '#include <stdio.h>'?
    2 | #include <stdio.h>
  +++ |+#include <stdio.h>
    3 | 
fclose.c:21:44: note: each undeclared identifier is reported only once for each function it appears in
   21 |         if((rv = sfclose(sf)) >= 0 && f != stdin && f != stdout && f != stderr)
      |                                            ^~~~~
fclose.c:21:58: error: 'stdout' undeclared (first use in this function)
   21 |         if((rv = sfclose(sf)) >= 0 && f != stdin && f != stdout && f != stderr)
      |                                                          ^~~~~~
fclose.c:21:58: note: 'stdout' is defined in header '<stdio.h>'; did you forget to '#include <stdio.h>'?
fclose.c:21:73: error: 'stderr' undeclared (first use in this function)
   21 |         if((rv = sfclose(sf)) >= 0 && f != stdin && f != stdout && f != stderr)
      |                                                                         ^~~~~~
fclose.c:21:73: note: 'stderr' is defined in header '<stdio.h>'; did you forget to '#include <stdio.h>'?

How do I fix this?