Re: cast pid_t to int when using *printf

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Magnus Hagander <mha(at)sollentuna(dot)net>, Oliver Jowett <oliver(at)opencloud(dot)com>, Neil Conway <neilc(at)samurai(dot)com>, pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: cast pid_t to int when using *printf
Date: 2004-10-09 02:42:00
Message-ID: 200410090242.i992g0g02291@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Peter Eisentraut wrote:
> Am Freitag, 24. September 2004 11:06 schrieb Magnus Hagander:
> > > (Btw., the Windows port defines pid_t as unsigned long;
> > > that's surely wrong.)
> >
> > In what way is that wrong? A PID on Windows is a DWORD, which is an
> > unsigned long. Or am I missing something (probably..)?
>
> The mingw header files define pid_t as int, so we shouldn't redefine it in the
> first place. The rest of the POSIX world also assumes that pid_t is signed,
> so you might break a bunch of interfaces if it's not. Note that this is
> independent of the fact that the actual process identifiers are all positive,
> both on Windows and on Unix systems.
>
> (Tertiary note: Never #define one type to another, always use typedef.)

I have fixed the Win32 type defines and removed the pid_t because as you
mentioned it was not needed. We only have these left and converted to
typedef:

typedef int uid_t;
typedef int gid_t;
typedef long key_t;

--
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

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2004-10-09 02:42:47 Re: cast pid_t to int when using *printf
Previous Message Bruce Momjian 2004-10-09 01:29:24 Re: [HACKERS] Log line prefix on win32