Re: [pgsql-hackers-win32] snprintf causes regression tests

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Nicolai Tufar <ntufar(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <mha(at)sollentuna(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, PostgreSQL Win32 port list <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: Re: [pgsql-hackers-win32] snprintf causes regression tests
Date: 2005-03-20 05:11:18
Message-ID: 200503200511.j2K5BIA06139@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-hackers-win32 pgsql-patches


Thanks to Andrew Dunstan, I found the cause of these link errors.
Andrew found this in libintl:

#undef snprintf
#define snprintf libintl_snprintf
extern int snprintf (char *, size_t, const char *, ...);

What is happening is that we do:

#define snprintf pg_snprintf

and then libintl.h (?) does:

#define snprintf libintl_snprintf

so the effect is:

#define pg_snprintf libintl_snprintf

In fact, in this example, the system complains about a missing X3 symbol:

#define X1 X2
#define X2 X3

int
main(int argc, char *argv[])
{
X1;
}

so the effet of the defines is:

#define X1 X3

Anyway, the reason ecpg is failing is that it is the only client-side
program that doesn't use libintl for internationalization. It is on our
TODO list to do that, but it hasn't been done yet.

However, only Win32 is seeing this failure, and only when configure
--enable-nls. I think this is because only Win32 does the redefine of
snprint and friends.

Comments?

---------------------------------------------------------------------------

Nicolai Tufar wrote:
> On Wed, 16 Mar 2005 01:00:21 -0500 (EST), Bruce Momjian
> <pgman(at)candle(dot)pha(dot)pa(dot)us> wrote:
> >
> > I have applied a modified version of your patch, attached.
>
> I am so sorry, I sent untested patch again. Thank you very
> much for patience in fixing it. The patch looks perfectly
> fine and works under Solaris.
>
> Under win32 I am still struggling with build environment.
> In many directories link fails with "undefined reference to
> `pg_snprintf'" in other it fails with "undefined reference to
> `_imp__libintl_sprintf'". In yet another directory it fails with
> both, like in src/interfaces/ecpg/pgtypeslib:
>
> dlltool --export-all --output-def pgtypes.def numeric.o datetime.o
> common.o dt_common.o timestamp.o interval.o pgstrcasecmp.o
> dllwrap -o libpgtypes.dll --dllname libpgtypes.dll --def pgtypes.def
> numeric.o datetime.o common.o dt_common.o timestamp.o interval.o
> pgstrcasecmp.o -L../../../../src/port -lm
> numeric.o(.text+0x19ea):numeric.c: undefined reference to
> `_imp__libintl_sprintf'
> datetime.o(.text+0x476):datetime.c: undefined reference to `pg_snprintf'
> common.o(.text+0x1cd):common.c: undefined reference to `pg_snprintf'
> common.o(.text+0x251):common.c: undefined reference to `pg_snprintf'
> dt_common.o(.text+0x538):dt_common.c: undefined reference to
> `_imp__libintl_sprintf'
> dt_common.o(.text+0x553):dt_common.c: undefined reference to
> `_imp__libintl_sprintf'
> dt_common.o(.text+0x597):dt_common.c: undefined reference to
> `_imp__libintl_sprintf'
> dt_common.o(.text+0x5d5):dt_common.c: undefined reference to
> `_imp__libintl_sprintf'
> dt_common.o(.text+0x628):dt_common.c: undefined reference to
> `_imp__libintl_sprintf'
> dt_common.o(.text+0x7e8):dt_common.c: more undefined references to
> `_imp__libintl_sprintf' follow
> c:\MinGW\bin\dllwrap.exe: c:\MinGW\bin\gcc exited with status 1
> make: *** [libpgtypes.a] Error 1
>
> Could someone with a better grasp of configure and
> win32 environment check it? Aparently no one regularily
> compiles source code under win32 during development cycle
> these days.
>
>
> Best regards,
> Nicolai
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2005-03-20 06:49:37 Re: [pgsql-hackers-win32] snprintf causes regression tests
Previous Message Tom Lane 2005-03-19 23:53:37 Avoiding unnecessary writes during relation drop and truncate

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Greg Stark 2005-03-20 06:49:37 Re: [pgsql-hackers-win32] snprintf causes regression tests
Previous Message Christopher Kings-Lynne 2005-03-18 02:00:01 Re: Changing the default wal_sync_method to open_sync for

Browse pgsql-patches by date

  From Date Subject
Next Message Greg Stark 2005-03-20 06:49:37 Re: [pgsql-hackers-win32] snprintf causes regression tests
Previous Message Marko Kreen 2005-03-19 23:45:57 [patch 6/6] regression test updates