Re: Rename StrNCpy to avoid conflictions on win32

Lists: pgsql-hackers
From: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Rename StrNCpy to avoid conflictions on win32
Date: 2009-09-07 02:40:13
Message-ID: 20090907113529.C853.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

We define StrNCpy() macro in c.h, but it conflicts another macro
defined in Microsoft SDKs:

C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\shlwapi.h(435)
: warning C4005: 'StrNCpy' : macro redefinition

Can we rename StrNCpy() macro to another name? (ex. pg_strncpy)
There might be some places to replace it to strlcpy() instead.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Rename StrNCpy to avoid conflictions on win32
Date: 2009-09-07 09:36:24
Message-ID: 9837222c0909070236w7bb305fmb1a6fe5f6d531df@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Sep 7, 2009 at 04:40, Itagaki
Takahiro<itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> wrote:
> We define StrNCpy() macro in c.h, but it conflicts another macro
> defined in Microsoft SDKs:
>
>    C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\shlwapi.h(435)
>        : warning C4005: 'StrNCpy' : macro redefinition
>
> Can we rename StrNCpy() macro to another name? (ex. pg_strncpy)

+1.

> There might be some places to replace it to strlcpy() instead.

Can't comment on that without looking at the code, but it wouldn't surprise me.

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Rename StrNCpy to avoid conflictions on win32
Date: 2009-09-07 10:28:16
Message-ID: 1252319296.29289.24.camel@fsopti579.F-Secure.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, 2009-09-07 at 11:36 +0200, Magnus Hagander wrote:
> On Mon, Sep 7, 2009 at 04:40, Itagaki
> Takahiro<itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> wrote:
> > There might be some places to replace it to strlcpy() instead.
>
> Can't comment on that without looking at the code, but it wouldn't surprise me.

There are some performance tradeoffs between these variants, and we
already did change all (most?) of the not performance-critical calls to
strlcpy a while ago.


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Rename StrNCpy to avoid conflictions on win32
Date: 2009-09-18 13:34:38
Message-ID: 200909181334.n8IDYcd19141@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut wrote:
> On Mon, 2009-09-07 at 11:36 +0200, Magnus Hagander wrote:
> > On Mon, Sep 7, 2009 at 04:40, Itagaki
> > Takahiro<itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> wrote:
> > > There might be some places to replace it to strlcpy() instead.
> >
> > Can't comment on that without looking at the code, but it wouldn't surprise me.
>
> There are some performance tradeoffs between these variants, and we
> already did change all (most?) of the not performance-critical calls to
> strlcpy a while ago.

Of all the macro names we use, I would have bet StrNCpy() was the last
one that would have conflicted with anything. :-O Did they copy it
from our code?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

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