Clients do not compile with X11 includes under C++ - Mailing list pgsql-bugs

From Hauke Joachim Zuehl
Subject Clients do not compile with X11 includes under C++
Date
Msg-id 3AC7BDCC.EACAFD10@athene.owl.de
Whole thread Raw
List 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
 / \

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: segmentation fault in psql
Next
From: Lonnie Cumberland
Date:
Subject: PostgreSQL tcp connection