Thread: C++ and v7.3.2
Hello all, I have just started working with C++ and am trying to get it to compile an app for PGSQL and well it has errors: I am using the test files that came with 7.2.1 (they did not work with 7.2.1 either) any thoughts? c++ testlibpq0.cc -o test.app In file included from pgsql/libpq++.h:27, from testlibpq0.cc:18: pgsql/libpq++/pgconnection.h:86: ISO C++ forbids declaration of `string' with no type pgsql/libpq++/pgconnection.h:86: parse error before `(' In file included from pgsql/libpq++.h:29, from testlibpq0.cc:18: pgsql/libpq++/pglobject.h:42: syntax error before `;' pgsql/libpq++/pglobject.h:61: syntax error before `(' In file included from pgsql/libpq++.h:31, from testlibpq0.cc:18: pgsql/libpq++/pgcursordb.h:53: `string' was not declared in this scope pgsql/libpq++/pgcursordb.h:53: parse error before `,' pgsql/libpq++/pgcursordb.h:62: `string' was not declared in this scope pgsql/libpq++/pgcursordb.h:62: parse error before `)' pgsql/libpq++/pgcursordb.h:65: `string' was not declared in this scope pgsql/libpq++/pgcursordb.h:65: parse error before `,' pgsql/libpq++/pgcursordb.h:68: syntax error before `;' pgsql/libpq++/pgcursordb.h: In method `const char *PgCursor::Cursor () const': pgsql/libpq++/pgcursordb.h:59: `pgCursor' undeclared (first use this function) pgsql/libpq++/pgcursordb.h:59: (Each undeclared identifier is reported only once for each function it appears in.) pgsql/libpq++/pgcursordb.h: In method `void PgCursor::Cursor (...)': pgsql/libpq++/pgcursordb.h:62: `cursor' undeclared (first use this function) testlibpq0.cc: In function `int main ()': testlibpq0.cc:34: `string' undeclared (first use this function) testlibpq0.cc:34: parse error before `;' testlibpq0.cc:40: `buf' undeclared (first use this function) testlibpq0.cc:40: `getline' undeclared (first use this function)
It looks like a namespace problem. string is in the std namespace, and just using "string" will not work unless you have a "using namespace std;" or by putting "std::string" instead of "string". - Erwin On Thu, 2003-04-24 at 19:14, Dev wrote: > Hello all, > > I have just started working with C++ and am trying to get it to compile an > app for PGSQL and well it has errors: > I am using the test files that came with 7.2.1 (they did not work with > 7.2.1 either) > > any thoughts? > > c++ testlibpq0.cc -o test.app > In file included from pgsql/libpq++.h:27, > from testlibpq0.cc:18: > pgsql/libpq++/pgconnection.h:86: ISO C++ forbids declaration of > `string' with no type > pgsql/libpq++/pgconnection.h:86: parse error before `(' > In file included from pgsql/libpq++.h:29, > from testlibpq0.cc:18: > pgsql/libpq++/pglobject.h:42: syntax error before `;' > pgsql/libpq++/pglobject.h:61: syntax error before `(' > In file included from pgsql/libpq++.h:31, > from testlibpq0.cc:18: > pgsql/libpq++/pgcursordb.h:53: `string' was not declared in this scope > pgsql/libpq++/pgcursordb.h:53: parse error before `,' > pgsql/libpq++/pgcursordb.h:62: `string' was not declared in this scope > pgsql/libpq++/pgcursordb.h:62: parse error before `)' > pgsql/libpq++/pgcursordb.h:65: `string' was not declared in this scope > pgsql/libpq++/pgcursordb.h:65: parse error before `,' > pgsql/libpq++/pgcursordb.h:68: syntax error before `;' > pgsql/libpq++/pgcursordb.h: In method `const char *PgCursor::Cursor () > const': > pgsql/libpq++/pgcursordb.h:59: `pgCursor' undeclared (first use this > function) > pgsql/libpq++/pgcursordb.h:59: (Each undeclared identifier is reported > only once for each function it appears in.) > pgsql/libpq++/pgcursordb.h: In method `void PgCursor::Cursor (...)': > pgsql/libpq++/pgcursordb.h:62: `cursor' undeclared (first use this > function) > testlibpq0.cc: In function `int main ()': > testlibpq0.cc:34: `string' undeclared (first use this function) > testlibpq0.cc:34: parse error before `;' > testlibpq0.cc:40: `buf' undeclared (first use this function) > testlibpq0.cc:40: `getline' undeclared (first use this function) > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly -- Dipl.-Ing. Erwin Rol - Software Engineering tel: +49-(0)8024-479377 gsm: +49-(0)171-6929198 fax: +49-(0)8024-479379 email: erwin@muffin.org
Attachment
Erwin Rol <erwin@muffin.org> writes: > It looks like a namespace problem. string is in the std namespace, and > just using "string" will not work unless you have a "using namespace > std;" or by putting "std::string" instead of "string". It might be a good idea to look at libpqxx from gborg.postgresql.org. libpq++ is old, crufty, and not really being maintained (it's not part of the standard PG distribution as of 7.3). regards, tom lane
I thought namespace::standard was well, standard, default? Tom Lane wrote: > Erwin Rol <erwin@muffin.org> writes: > >>It looks like a namespace problem. string is in the std namespace, and >>just using "string" will not work unless you have a "using namespace >>std;" or by putting "std::string" instead of "string". > > > It might be a good idea to look at libpqxx from gborg.postgresql.org. > libpq++ is old, crufty, and not really being maintained (it's not part > of the standard PG distribution as of 7.3). > > regards, tom lane > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster >
Dennis Gearon <gearond@cvc.net> writes: > I thought namespace::standard was well, standard, default? The C++ "standard" was a moving target for so long that it's not funny. libpq++ made some effort to handle several generations of the spec, but it may not handle the latest. Or it may be configured wrong for the OP's compiler; I dunno where he got the libpq++ sources from, but it sure wasn't an official Postgres 7.3 release ... regards, tom lane