Обсуждение: errcode redefinition
I am trying to build the Postgres drivers for Qt on Windows. I am consistantly running into a problem where the Postgresfunction "errcode" conflicts with a typedef of the stame name (typedef int errcode). Has anyone else had this problem? Has anyone solved this problem? Is there a better list to post this to? According to the archives (http://archives.postgresql.org/pgsql-hackers/2006-05/msg01259.php), there is a patch applied tothe 8.1 stable branch (http://archives.postgresql.org/pgsql-hackers/2006-05/msg01317.php) but compiling that branch andbuilding with that does not fix the problem. Version information: Postgres 8.1, but I'd settle for any 7.x or 8.x I have successfully installed the 8.1 version (binaries for windows), and I have also successfully built the postgreslibraries from CVS source (REL8_1_STABLE branch). Visual Studio 2005, Standard edition Qt 3.3.6, Enterprise edition Windows XP 2002 SP2 Cygwin This appears to be specific to VS2005. VS6 plays well with Postgres 7.4, and VS.NET 2002 plays well with Postgres 8.0 The error message: "C:\Program Files\Microsoft Visual Studio 8\VC\BIN\nmake.exe" cl -c -FIqt_pch.h -Yuqt_pch.h -Fptmp\obj\debug_mt_shared\qt-mt_pch.pch -nologo -Zm200 -wd4996 -W3 -w34100 -w34189-MDd -Zi -EHsc -EHsc -GR -DQT_SHARED -DQT_THREAD_SUPPORT -DQT_ACCESSIBILITY_SUPPORT -DUNICODE -DWIN32 -DQT_MAKEDLL-DQT_THREAD_SUPPORT -DQT_NO_CUPS -DQT_NO_NIS -DQT_SQL_POSTGRES -DQT_NO_IMAGEIO_MNG -DQT_NO_STYLE_MAC -DQT_NO_STYLE_AQUA-DQT_NO_STYLE_INTERLACE -DQT_NO_STYLE_WINDOWSXP -DQT_NO_STYLE_COMPACT -DQT_NO_STYLE_POCKETPC -DQT_DLL -DQT_MAKEDLL-I"C:\Postgres\8.1\include" -I"C:\Postgres\8.1\include\server" -I"tmp" -I"3rdparty\libjpeg" -I"3rdparty\libpng"-I"3rdparty\zlib" -I"C:\Qt\3.3.6\include" -I"." -I"tmp\moc\debug_mt_shared" -I"C:\Qt\3.3.6\mkspecs\win32-msvc2005"-Fotmp\obj\debug_mt_shared\ @C:\DOCUME~1\DEVELO~1\LOCALS~1\Temp\nm30D.tmp qsql_psql.cpp c:\postgres\8.1\include\server\utils/elog.h(105) : error C2365: 'errcode' : redefinition; previous definition was 'typedef' C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\crtdefs.h(506) : see declaration of 'errcode' There were also other problems with missing header files and "configure" oddities but I worked around these. Any help would be greatly appreciated. -Andrew Vick
Andrew Vick <avick@remote-print.com> writes: > I am trying to build the Postgres drivers for Qt on Windows. Why are these drivers trying to include elog.h? That's a backend-only header. If the reason is that they're including postgres.h, they should likely be including postgres_fe.h instead. regards, tom lane
Tom Lane wrote: > Andrew Vick <avick@remote-print.com> writes: > >>I am trying to build the Postgres drivers for Qt on Windows. > > > Why are these drivers trying to include elog.h? That's a backend-only > header. If the reason is that they're including postgres.h, they should > likely be including postgres_fe.h instead. That is the case. I tried switching it to postgres_fe.h, but then I got errors about the pg_type structure not being defined. It appears that the CATALOG macro (which defines the structure) is defined in postgres.h but not in postgres_fe.h. I don't see any other headers in src/ which do define it. I worked around this by switching back to postgres.h, and #defining ELOG_H above postgres.h (to block elog.h). Nonoptimal,but it gets the compile going again. Thanks for the suggestion; knowing that elog.h was backend only gave me the courage to exclude it. -Andrew Vick
Andrew Vick <avick@remote-print.com> writes: > Tom Lane wrote: >> Why are these drivers trying to include elog.h? That's a backend-only >> header. If the reason is that they're including postgres.h, they should >> likely be including postgres_fe.h instead. > That is the case. I tried switching it to postgres_fe.h, but then I > got errors about the pg_type structure not being defined. Where were those coming from? I'm trying to burrow down to what they're really after that's forcing them to include headers they shouldn't be including ... regards, tom lane
Tom Lane wrote: > Andrew Vick <avick@remote-print.com> writes: > >>Tom Lane wrote: >> >>>Why are these drivers trying to include elog.h? That's a backend-only >>>header. If the reason is that they're including postgres.h, they should >>>likely be including postgres_fe.h instead. > > >>That is the case. I tried switching it to postgres_fe.h, but then I >>got errors about the pg_type structure not being defined. > > > Where were those coming from? I'm trying to burrow down to what they're > really after that's forcing them to include headers they shouldn't be > including ... > In Postgres, the errors were coming from pg_type.h. In Qt. they were coming from src/sql/drivers/psql/qsql_psql.cpp. I've glanced through the Qt source, and I don't see any places where they try to access the members of any Postgres structures. I believe Qt is just wrapping the C interface to the Postgres libraries; maybe the problem is that this versionof Qt (3.3.6) is too old for this version of Postgres (8.1 stable). Perhaps the Postgres headers have changed sincethe 8.0 release to cause this, and this release of Qt predates the change. If it weren't for that problem with errcode,I might be using an earlier version of Postgres. -Andrew
Andrew Vick <avick@remote-print.com> writes: > Tom Lane wrote: >> Where were those coming from? I'm trying to burrow down to what they're >> really after that's forcing them to include headers they shouldn't be >> including ... > In Postgres, the errors were coming from pg_type.h. > In Qt. they were coming from src/sql/drivers/psql/qsql_psql.cpp. > I've glanced through the Qt source, and I don't see any places where > they try to access the members of any Postgres structures. If you remove the inclusion of pg_type.h, does it build? I'm thinking maybe the reason for this pushup is that they need access to the type OID macros in pg_type.h (INT4OID and friends). I've been thinking that we need to provide a way for frontend apps to use those macros without including a bunch of backend-only stuff --- if that's what's going on here, that would be ammunition to propose a change. I'd appreciate it if you include postgres_fe.h instead of postgres.h, remove any other PG header inclusions that cause errors without postgres.h, and then see what errors are left in the Qt code. regards, tom lane