Rename StrNCpy to avoid conflictions on win32

Started by Itagaki Takahiroover 16 years ago4 messages
#1Itagaki Takahiro
itagaki.takahiro@oss.ntt.co.jp

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

#2Magnus Hagander
magnus@hagander.net
In reply to: Itagaki Takahiro (#1)
Re: Rename StrNCpy to avoid conflictions on win32

On Mon, Sep 7, 2009 at 04:40, Itagaki
Takahiro<itagaki.takahiro@oss.ntt.co.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/

#3Peter Eisentraut
peter_e@gmx.net
In reply to: Magnus Hagander (#2)
Re: Rename StrNCpy to avoid conflictions on win32

On Mon, 2009-09-07 at 11:36 +0200, Magnus Hagander wrote:

On Mon, Sep 7, 2009 at 04:40, Itagaki
Takahiro<itagaki.takahiro@oss.ntt.co.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.

#4Bruce Momjian
bruce@momjian.us
In reply to: Peter Eisentraut (#3)
Re: Rename StrNCpy to avoid conflictions on win32

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.takahiro@oss.ntt.co.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@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

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