[GRASS-dev] Removing _STDIO_H ifndefs

Vaclav Petras wenzeslaus at gmail.com
Thu Dec 5 19:57:17 PST 2013


Hi all,

there are some preprocessor ifndefs which I don't completely understand
but, from what I understand, they should be removed.

There are two contexts where it is used:

#ifndef _STDIO_H
#include <stdio.h>
#endif

which is useless since this check should be done in stdio.h.

The other usage is:

#ifdef _STDIO_H
int do_label(FILE *, int);
#endif

which in case of not defined _STDIO_H will not declare that function and so
it will break the code later in the compilation where this function is used
(depending code is not marked by #ifdef).

It actually breaks with standard C library which does not define _STDIO_H
but something else, e.g. the one which goes with the latest Mac OS X XCode
(at least to my current understanding). I guess there is not reason to to
"ifdef stdio.h" any parts of code now, so we can just remove all these.

Patch attached, once it is approved I will commit it. Compiled so far only
on Ubuntu.

Objections? Explanations?

Vaclav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20131205/eeb782fc/attachment.html>
-------------- next part --------------
Index: include/defs/dig_atts.h
===================================================================
--- include/defs/dig_atts.h	(revision 58395)
+++ include/defs/dig_atts.h	(working copy)
@@ -1,6 +1,4 @@
-#ifndef _STDIO_H
 #include <stdio.h>
-#endif
 
 /*
    #define              WRITE_ATT_FORMAT        "%c  %12.2lf  %12.2lf  %8d"
Index: include/bitmap.h
===================================================================
--- include/bitmap.h	(revision 58395)
+++ include/bitmap.h	(working copy)
@@ -33,9 +33,7 @@
     struct BMlink *next;
 };
 
-#ifndef _STDIO_H
 #include <stdio.h>
-#endif
 
 #include <grass/defs/bitmap.h>
 
Index: include/vect/dig_structs.h
===================================================================
--- include/vect/dig_structs.h	(revision 58395)
+++ include/vect/dig_structs.h	(working copy)
@@ -13,10 +13,7 @@
 #ifndef  DIG___STRUCTS___
 #define DIG___STRUCTS___
 
-/*  this file depends on <stdio.h> */
-#ifndef _STDIO_H
 #include <stdio.h>
-#endif
 
 #include <sys/types.h>
 
Index: ps/ps.map/local_proto.h
===================================================================
--- ps/ps.map/local_proto.h	(revision 58395)
+++ ps/ps.map/local_proto.h	(working copy)
@@ -42,9 +42,8 @@
 /* do_labels.c */
 int do_labels(int);
 
-#ifdef _STDIO_H
 int do_label(FILE *, int);
-#endif
+
 /* do_masking.c */
 int do_masking(void);
 
@@ -271,9 +270,8 @@
 int accept(void);
 int reject(void);
 
-#ifdef _STDIO_H
 int print_session(FILE *);
-#endif
+
 /* show_scale.c */
 int show_scale(void);
 
@@ -299,9 +297,8 @@
 int eps_bbox(char *, double *, double *, double *, double *);
 int eps_trans(double, double, double, double, double, double, double, double,
 	      double *, double *);
-#ifdef _STDIO_H
+
 int eps_save(FILE *, char *, char *);
 int eps_draw_saved(char *, double, double, double, double);
 int eps_draw(FILE *, char *, double, double, double, double);
 int pat_save(FILE *, char *, char *);
-#endif


More information about the grass-dev mailing list