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
(attachments)
remove_stdio_h_ifndef.diff (1.89 KB)
Since there were no objections, I committed the patch in r58435. Patch tested on Mac OS X Mavericks (clang) and Ubuntu (gcc, clang).
[r58435] https://trac.osgeo.org/grass/changeset/58435
On Mac:
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
(note that gcc on new mac is clang not gcc)
On Ubuntu:
$ clang --version
Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0)
Target: i386-pc-linux-gnu
Thread model: posix
$ gcc --version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
···
On Thu, Dec 5, 2013 at 10:57 PM, Vaclav Petras <wenzeslaus@gmail.com> wrote:
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