More #ifdef fun: src/interfaces/libpq/win32.c

Started by Tom Laneover 19 years ago3 messages
#1Tom Lane
tgl@sss.pgh.pa.us

src/interfaces/libpq/win32.c contains

/* Declared here to avoid pulling in all includes, which causes name collissions */
#ifdef ENABLE_NLS
extern char *
libpq_gettext(const char *msgid)
__attribute__((format_arg(1)));
#else
#define libpq_gettext(x) (x)
#endif

Now, since it has nowhere bothered to #include pg_config.h, ENABLE_NLS
will certainly not be defined, and so this code always fails to invoke
gettext.

This may not be real important since the file appears to use gettext
only here:

if (!success)
sprintf(strerrbuf, libpq_gettext("Unknown socket error (0x%08X/%i)"), err, err);

but it's still pretty bogus.

Without a Windows machine, I'm not in a position to try making this file
properly include postgres_fe.h, or at least c.h, but someone ought to
try harder.

regards, tom lane

#2Hiroshi Saito
z-saito@guitar.ocn.ne.jp
In reply to: Tom Lane (#1)
Re: More #ifdef fun: src/interfaces/libpq/win32.c

Hi Tom-san.

I think that it should be in this way.

#include "postgres_fe.h"
#ifdef WIN32
#include "win32.h"
#endif

However, I am still under try by the reason for seeing the error of now a few.

Regards,
Hiroshi Saito

----- Original Message -----
From: "Tom Lane"

Show quoted text

src/interfaces/libpq/win32.c contains

/* Declared here to avoid pulling in all includes, which causes name collissions */
#ifdef ENABLE_NLS
extern char *
libpq_gettext(const char *msgid)
__attribute__((format_arg(1)));
#else
#define libpq_gettext(x) (x)
#endif

Now, since it has nowhere bothered to #include pg_config.h, ENABLE_NLS
will certainly not be defined, and so this code always fails to invoke
gettext.

This may not be real important since the file appears to use gettext
only here:

if (!success)
sprintf(strerrbuf, libpq_gettext("Unknown socket error (0x%08X/%i)"), err, err);

but it's still pretty bogus.

Without a Windows machine, I'm not in a position to try making this file
properly include postgres_fe.h, or at least c.h, but someone ought to
try harder.

regards, tom lane

#3Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#1)
1 attachment(s)
Re: [HACKERS] More #ifdef fun: src/interfaces/libpq/win32.c

Tom Lane wrote:

src/interfaces/libpq/win32.c contains

/* Declared here to avoid pulling in all includes, which causes name collissions */
#ifdef ENABLE_NLS
extern char *
libpq_gettext(const char *msgid)
__attribute__((format_arg(1)));
#else
#define libpq_gettext(x) (x)
#endif

Now, since it has nowhere bothered to #include pg_config.h, ENABLE_NLS
will certainly not be defined, and so this code always fails to invoke
gettext.

This may not be real important since the file appears to use gettext
only here:

if (!success)
sprintf(strerrbuf, libpq_gettext("Unknown socket error (0x%08X/%i)"), err, err);

but it's still pretty bogus.

Without a Windows machine, I'm not in a position to try making this file
properly include postgres_fe.h, or at least c.h, but someone ought to
try harder.

I have applied the following patch to include postgres_fe.h in two
win32-specific files. I think the authors thought where was no
pg-specific code in there, but now there is, or might be in the future.
I see no reason to backpatch this.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

Attachments:

/bjm/difftext/x-diffDownload
Index: src/interfaces/libpq/pthread-win32.c
===================================================================
RCS file: /cvsroot/pgsql/src/interfaces/libpq/pthread-win32.c,v
retrieving revision 1.11
diff -c -c -r1.11 pthread-win32.c
*** src/interfaces/libpq/pthread-win32.c	5 Mar 2006 15:59:10 -0000	1.11
--- src/interfaces/libpq/pthread-win32.c	29 Jul 2006 15:03:44 -0000
***************
*** 10,15 ****
--- 10,16 ----
  *-------------------------------------------------------------------------
  */
  
+ #include "postgres_fe.h"
  
  #include <windows.h>
  #include "pthread-win32.h"
Index: src/interfaces/libpq/win32.c
===================================================================
RCS file: /cvsroot/pgsql/src/interfaces/libpq/win32.c,v
retrieving revision 1.17
diff -c -c -r1.17 win32.c
*** src/interfaces/libpq/win32.c	7 Jun 2006 22:24:46 -0000	1.17
--- src/interfaces/libpq/win32.c	29 Jul 2006 15:03:44 -0000
***************
*** 25,32 ****
  #endif
  #define NOCRYPT
  
! #include <windows.h>
! #include <stdio.h>
  #include "win32.h"
  
  /* Declared here to avoid pulling in all includes, which causes name collissions */ 
--- 25,32 ----
  #endif
  #define NOCRYPT
  
! #include "postgres_fe.h"
! 
  #include "win32.h"
  
  /* Declared here to avoid pulling in all includes, which causes name collissions */