[postgis-devel] Use of "bool" in C
Bryce L Nordgren
bnordgren at gmail.com
Wed Jun 22 11:53:47 PDT 2011
I stumbled across this when moving some functions from ./postgis to
./liblwgeom today. As it turns out, liblwgeom is compiled with gcc, whereas
postgis is compiled with g++...and it makes a difference.
bool is not a C keyword. Not even in C99. To use the C99 "bool" macro, you
must include <stdbool.h>. The name of the builtin type is _Bool. Macros for
true and false are TRUE and FALSE, respectively. I assume the only reason
that postgis compiles at all is that g++ is doing the compiling, and C++
rules apply.
To make the code from the postgis directory compile with a C compiler (e.g.,
in liblwgeom), I switched all "bool"s to "int"s.
http://stackoverflow.com/questions/1608318/is-bool-a-native-c-type
I suppose the relevant questions for devel are: Is PostGIS supposed to be a
C project or are C++ constructs allowed? Why are some C things compiled
with C++? How do you want to handle "bool"? :) food 4 thot
Bryce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20110622/27df2261/attachment.html>
More information about the postgis-devel
mailing list