From: Dilip on
Hello

The following message was posted at comp.std.c++ initially. Since its
slightly OT for that group I am reposting it here. When I tried to
simply forward the post here it didn't seem to work. So I am creating
a new post. Apologies in advance if it causes a redundant entry.

==Message follows======
Some of the code we write at my company runs on both UNIX systems
(mostly AIX) and Microsoft Windows systems. The code which was
originally written on UNIX contains a number of Posix function calls,
many of which compile and execute properly on Windows. We have
recently begun using the Microsoft Visual Studio .net 2005 compiler and
we now getting the following warning message about a number of Posix
calls.

..\wuu.c(790) : warning C4996: 'unlink' was declared deprecated
C:\Program Files\Microsoft Visual Studio
8\VC\include\stdio.h(290) :
see declaration of 'unlink'
Message: 'The POSIX name for this item is deprecated. Instead,
use
the ISO C++ conformant name: _unlink. See online help for details.'

Does anyone know what the reason for this is? I've read every C and
C++ book I own and searched the internet trying to find an explanation
for this change. For the life of me, I can't see how "_unlink" is any
more ISO C++ conformant than "unlink".

PS - Even after reading the charter of several newsgroups it wasn't
clear to me where a question like this belongs, so I cross-posted this
to a Windows newsgroup, figuring perhaps people there have heard an
explanation from Microsoft which I missed, and a C++ and UNIX
newsgroup, figuring you might have some insight on the issue of ISO C++
and Posix names. If there are more relevant groups, please redirect
the discussion as you see fit.

--
Tom Einertson E-mail:
t...(a)siemens-emis.com
SIEMENS Power Transmission & Distribution Phone: (952) 607-2244
Energy Management & Automation Division Fax: (952) 607-2018
10900 Wayzata Boulevard, Suite 400
Minnetonka, MN, 55305
=========Message ends==============================

From: Tim Roberts on
"Dilip" <rdilipk(a)lycos.com> wrote:
>
>Some of the code we write at my company runs on both UNIX systems
>(mostly AIX) and Microsoft Windows systems. The code which was
>originally written on UNIX contains a number of Posix function calls,
>many of which compile and execute properly on Windows. We have
>recently begun using the Microsoft Visual Studio .net 2005 compiler and
>we now getting the following warning message about a number of Posix
>calls.
>
>.\wuu.c(790) : warning C4996: 'unlink' was declared deprecated
> C:\Program Files\Microsoft Visual Studio
>8\VC\include\stdio.h(290) :
>see declaration of 'unlink'
> Message: 'The POSIX name for this item is deprecated. Instead,
>use the ISO C++ conformant name: _unlink. See online help for details.'
>
>Does anyone know what the reason for this is? I've read every C and
>C++ book I own and searched the internet trying to find an explanation
>for this change. For the life of me, I can't see how "_unlink" is any
>more ISO C++ conformant than "unlink".

Because "unlink" is not part of the ISO standard run-time library. It is a
vendor-defined (although extremely common) extension. Vendor-defined
functions are supposed to be defined with a leading underscore so they do
not collide with some poor user's program.

One quite reasonable way to handle this is

#pragma warning(disable:4996)

I find this equally as onerous as the "deprecation" of strcpy and friends.
--
- Tim Roberts, timr(a)probo.com
Providenza & Boekelheide, Inc.
From: Eugene Gershnik on
Tim Roberts wrote:
>
> Because "unlink" is not part of the ISO standard run-time library.
> It is a vendor-defined (although extremely common) extension.

It also happens to be defined by POSIX standard.

> Vendor-defined functions are supposed to be defined with a leading
> underscore so they do not collide with some poor user's program.
>
> One quite reasonable way to handle this is
>
> #pragma warning(disable:4996)

This is IMHO a bad idea because you disable *all* deprecation warnings no
matter what their source is. A better way is to either define __POSIX__ or
_CRT_NONSTDC_NO_DEPRECATE
for your compilation. The first macro is probably what OP is looking for
because he needs POSIX compatibility.

See crtdefs.h in VC include directory for further details.

> I find this equally as onerous as the "deprecation" of strcpy and
> friends.

My favorite is deprecated strerror(). ;-)

--
Eugene
http://www.gershnik.com