On Fri, Mar 28, 2014 at 5:40 PM, Glynn Clements <glynn@gclements.plus.com>wrote:
Vaclav Petras wrote:
> which C and C++ standards we are using? And which we want to use? Do we
> even care? Since we can always fix it if somebody wants to build GRASS on
> some other compiler than relatively new GCC.
C code is supposed to conform to C89 and POSIX.
There are no standards for C++ code.
I would say that for GCC, we should go with:
‘c++98’‘c++03’
The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
additional defect reports. Same as -ansi for C++ code.
(http://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#C-Dialect-Options)
I'll will set this for may compilation and see what will happen. The only
alternative is to say that all C++ capable compilers will be new anyway and
than we can go with latest (C++11 or later).
> For example, lib/gis build fails with gcc option -std=c89 [1] because of
> missing `hypot` buildin [2].
hypot() is specified by POSIX.
Using -std=c89 or -ansi will, by default, omit the POSIX extensions
from any headers which are specified by C89. To re-enable them, you
need something along the lines of:
-D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE -D_SVID_SOURCE
We already require POSIX for open() etc, so there isn't much point in
excluding POSIX functions which are declared in the C89 headers.
Hm, I hoped that I missed some -posix in GCC but there is apparently none.
And if you are unsure about that -D options, I don't know how to enforce
the right standards.
So, we have all GNU GCC extensions enabled which is good in the sense that
we have many functions available. The bad thing is that it is hard to say
which are allowed without looking to the standard.
--
Glynn Clements <glynn@gclements.plus.com>