I have compiled PostgreSQL 7.1.2 with gcc 3.0.1, and have the following
problem: if I include first libpq++.h before iostream, id est:

#include <libpq++.h>
#include <iostream>

the compiler complains:

In file included from /usr/include/g++-v3/bits/locale_facets.tcc:38,
                 from /usr/include/g++-v3/bits/std_locale.h:41,
                 from /usr/include/g++-v3/bits/ostream.tcc:32,
                 from /usr/include/g++-v3/bits/std_ostream.h:278,
                 from /usr/include/g++-v3/bits/std_iostream.h:40,
                 from /usr/include/g++-v3/iostream:31,
                 from p.cc:3:
/usr/include/g++-v3/bits/std_limits.h:286:5: missing binary operator
/usr/include/g++-v3/bits/std_limits.h:483:5: missing binary operator


This is because somewhere in PostgreSQL you have the following code:

#ifndef true
#define true ((bool)1)
#endif

and it seems that in gcc 3.0.1, "true" is not defined, or that "true" is
a reserved word doesn't mean that is defined, or that the offending
lines below they don't exist in std_limit.h, I don't know as I no longer
have the old compiler. The workaround is to include first iostream, and
then libpq++. The offending lines in std_limits.h are the following:

#ifdef __CHAR_UNSIGNED__
#define __glibcpp_plain_char_is_signed false
#else
#define __glibcpp_plain_char_is_signed true
#endif

end somewhere below this one:

#if __glibcpp_plain_char_is_signed
#endif

which is preprocessed to:

#if true
#endif

when the #include<iostream> is before libpq++ and:

#if ((bool)1)
#endif

otherwise. This last statement is invalid for the compiler.

Leandro Fanzone


Fri, 24 Aug 2001 17:12:19 -0300
Leandro Fanzone <leandro@hasar.com>
gcc 3.0.1
Leandro Fanzone <leandro@hasar.com> writes:
> I have compiled PostgreSQL 7.1.2 with gcc 3.0.1, and have the following
> problem: if I include first libpq++.h before iostream, id est:
> #include <libpq++.h>
> #include <iostream>
> the compiler complains:

> This is because somewhere in PostgreSQL you have the following code:

> #ifndef true
> #define true ((bool)1)
> #endif

Yeah.  c.h has

#ifndef __cplusplus
#ifndef bool
typedef char bool;
#endif	 /* ndef bool */
#endif	 /* not C++ */

#ifndef true
#define true	((bool) 1)
#endif

#ifndef false
#define false	((bool) 0)
#endif

It's been like that for quite some time, but it's always struck me as
bizarre: if we're willing to trust a C++ compiler to provide type
bool, why would we not trust it to provide the literals true and false
as well?  ISTM the code should read

#ifndef __cplusplus

#ifndef bool
typedef char bool;
#endif

#ifndef true
#define true	((bool) 1)
#endif

#ifndef false
#define false	((bool) 0)
#endif

#endif	 /* not C++ */

Does anyone have an objection to this?

			regards, tom lane

Sun, 26 Aug 2001 02:42:00 -0400
Tom Lane <tgl@sss.pgh.pa.us>
C++ and bool constants (was Re: [NOVICE] gcc 3.0.1)

I like the change.

> Leandro Fanzone <leandro@hasar.com> writes:
> > I have compiled PostgreSQL 7.1.2 with gcc 3.0.1, and have the following
> > problem: if I include first libpq++.h before iostream, id est:
> > #include <libpq++.h>
> > #include <iostream>
> > the compiler complains:
> 
> > This is because somewhere in PostgreSQL you have the following code:
> 
> > #ifndef true
> > #define true ((bool)1)
> > #endif
> 
> Yeah.  c.h has
> 
> #ifndef __cplusplus
> #ifndef bool
> typedef char bool;
> #endif	 /* ndef bool */
> #endif	 /* not C++ */
> 
> #ifndef true
> #define true	((bool) 1)
> #endif
> 
> #ifndef false
> #define false	((bool) 0)
> #endif
> 
> It's been like that for quite some time, but it's always struck me as
> bizarre: if we're willing to trust a C++ compiler to provide type
> bool, why would we not trust it to provide the literals true and false
> as well?  ISTM the code should read
> 
> #ifndef __cplusplus
> 
> #ifndef bool
> typedef char bool;
> #endif
> 
> #ifndef true
> #define true	((bool) 1)
> #endif
> 
> #ifndef false
> #define false	((bool) 0)
> #endif
> 
> #endif	 /* not C++ */
> 
> Does anyone have an objection to this?
> 
> 			regards, tom lane
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Sun, 26 Aug 2001 12:49:22 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: C++ and bool constants (was Re: [NOVICE] gcc 3.0.1)
Fine for me also.

Leandro.

Tom Lane wrote:

> Leandro Fanzone <leandro@hasar.com> writes:
> > I have compiled PostgreSQL 7.1.2 with gcc 3.0.1, and have the following
> > problem: if I include first libpq++.h before iostream, id est:
> > #include <libpq++.h>
> > #include <iostream>
> > the compiler complains:
>
> > This is because somewhere in PostgreSQL you have the following code:
>
> > #ifndef true
> > #define true ((bool)1)
> > #endif
>
> Yeah.  c.h has
>
> #ifndef __cplusplus
> #ifndef bool
> typedef char bool;
> #endif   /* ndef bool */
> #endif   /* not C++ */
>
> #ifndef true
> #define true    ((bool) 1)
> #endif
>
> #ifndef false
> #define false   ((bool) 0)
> #endif
>
> It's been like that for quite some time, but it's always struck me as
> bizarre: if we're willing to trust a C++ compiler to provide type
> bool, why would we not trust it to provide the literals true and false
> as well?  ISTM the code should read
>
> #ifndef __cplusplus
>
> #ifndef bool
> typedef char bool;
> #endif
>
> #ifndef true
> #define true    ((bool) 1)
> #endif
>
> #ifndef false
> #define false   ((bool) 0)
> #endif
>
> #endif   /* not C++ */
>
> Does anyone have an objection to this?
>
>                         regards, tom lane


Mon, 27 Aug 2001 09:49:23 -0300
Leandro Fanzone <leandro@hasar.com>
Re: C++ and bool constants (was Re: [NOVICE] gcc 3.0.1)