Clients do not compile with X11 includes under C++

From: Hauke Joachim Zuehl <hzuehl(at)athene(dot)owl(dot)de>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Clients do not compile with X11 includes under C++
Date: 2001-04-01 23:46:20
Message-ID: 3AC7BDCC.EACAFD10@athene.owl.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello Team :)

With help of a programmers newsgroup I could solve the problem of not
compiling (Linux) C++ clients using X11 and pgsql/libpq++/pgconnection.h
(included via pgdatabase.h).

Well, I tried the following:
g++ -c kunde.cc -o kunde.o -I/usr/local/include -D__WXMOTIF__
-D_REENTRANT -O2 -I/usr/include/pgsql/libpq++ -I/usr/include/pgsql \
-I/usr/include/X11

The error message was the following:
/usr/include/pgsql/libpq++/pgconnection.h:69: extraneous `int' ignored
/usr/include/pgsql/libpq++/pgconnection.h:69: parse error before `('

The -D__WXMOTIF__ is necessary for wxWindows which also includes
X11/Xlib.h.

So I posted this to a newsgroup.

The answer was quite simple: "In X11/Xlib.h you find a line where
"#define Status int" is used."

So next thing I did was to add the following lines into my program /
header files:

#ifdef Status
#undef Status
#endif

before including the PostgreSQL C++ header.

Remember:
In line 69 of pgconnection.h you may find
ConnStatusType Status();

and _without_ undefining Status the result is
ConnStatusType int();
which causes the error.

After adding the above three lines the source was compiled without
errors.

So to avoid problems you should undefine Status in your header-file.

My version of PostgreSQL is 7.0.2 (installed from a SuSE 7.0 CD).

Regards,
Hauke
--
/"\
\ / ASCII Ribbon Campaign
x Say NO to HTML in email and news
/ \

Browse pgsql-bugs by date

  From Date Subject
Next Message Christopher Kings-Lynne 2001-04-02 01:31:43 RE: [HACKERS] Error in the date field (with NULL value...).Thanks!
Previous Message Tom Lane 2001-04-01 17:47:18 Re: segmentation fault in psql