Visual Studio 8 build warnings

Bug #541268 reported by Jeff Hill
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
Fix Released
Wishlist
Jeff Hill

Bug Description

From Ken Evans

There are two sets of deprecated functions and an option reported as deprecated by Visual Studio 8. The issues seem to have been fixed by changing the following configuration files for 3.14.8.2 as described below:

configure/os/CONFIG.win32-x86.win32-x86
config/CONFIG.Host.WIN32

1. Many functions are now listed as possibly unsafe. (Because Microsoft has introduced new "secure" versions.) Define _CRT_SECURE_NO_DEPRECATE to eliminate these warnings:

xgif.c
../xgif.c(226) : warning C4996: 'strcpy' was declared deprecated
        C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\string.h(73) : see declaration of 'strcpy'
        Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'

2. The following option is reported as deprecated:

cl /GX /GR /nologo /D__STDC__=0 /Ox /W3 /DXMSTATIC /DMOTIFAPP /DWIN32
/D_WINDOWS /MD -I. -I.. -Ic:/Exceed/Exceed/xdk/include
-Ic:/Exceed/Exceed/xdk/include -I../../../include/os/WIN32 -I../../../include -I../../../../base3.14.8test/include/os/WIN32
-I../../../../base3.14.8test/include -c /Tp ../CGif.cpp
cl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future release cl : Command line warning D9036 : use 'EHsc' instead of 'GX' CGif.cpp

Note: /EHsc should work with MSVC 7, too.

3. There are others for which the POSIX name is deprecated Define _CRT_NONSTDC_NO_DEPRECATE to eliminate these warnings, possibly at the expense of eliminating warnings about other deprecated functions:

osdEnv.c
..\..\..\src\libCom\osi\os\default\osdEnv.c(45) : warning C4996: 'putenv' was declared deprecated
        C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\stdlib.h(822)
: see declaration of 'putenv'
        Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _putenv. See online help for details.'

epicsTempFile.cpp
..\..\..\src\libCom\osi\os\WIN32\epicsTempFile.cpp(81) : warning C4996: 'open' was declared deprecated
        C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\io.h(328) : see declaration of 'open'
        Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _open. See online help for details.'

scan.l(682) : warning C4996: 'fileno' was declared deprecated
        C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\stdio.h(688) : see declaration of 'fileno'
        Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details.'

..\main.c(224) : 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.'
..\iocUtil.c(33) : warning C4996: 'chdir' was declared deprecated
        C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\direct.h(127)
: see declaration of 'chdir'
        Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _chdir. See online help for details.'

..\iocUtil.c(44) : warning C4996: 'getcwd' was declared deprecated
        C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\direct.h(121)
: see declaration of 'getcwd'
        Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getcwd. See online help for details.'

..\epicsStdioTest.c(80) : warning C4996: 'fdopen' was declared deprecated
        C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\stdio.h(686) : see declaration of 'fdopen'
        Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fdopen. See online help for details.'

Original Mantis Bug: mantis-233
    http://www.aps.anl.gov/epics/mantis/view_bug_page.php?f_id=233

Tags: 3.14
Revision history for this message
Jeff Hill (johill-lanl) wrote :

I had to fix a few things to get R3.14.8 to compile with Visual Studio 8. At this time I only have an evaluation copy. I have the upgrade on order.

> ../xgif.c(226) : warning C4996: 'strcpy' was declared deprecated
> C:\Program Files\Microsoft Visual Studio

I have not yet investigated to see how common this is in base. Certainly, deprecating strcpy might have been a bit hasty on MS' part. Nevertheless, I consider strncpy to almost always be a better option. I haven't looked yet to see if that version is also deprecated.

My initial thought is that this is probably another foolish thing that MS has done, but nevertheless it might be best to investigate the situation prior to suppressing the warnings. The system builds fine as it is after all.

> cl : Command line warning D9035 : option 'GX' has been deprecated and will
> be removed in a future release
> cl : Command line warning D9036 : use 'EHsc' instead of 'GX'

We could switch to EHsc, but I wonder if the VC 6 build will break :-(. I believe that it is currently ok).

> Message: 'The POSIX name for this item is deprecated. Instead, use
> the ISO C++ conformant name: _open. See online help for details.'

The problem here might be my using #include of ANSI C header files where C++ header files could be used. It might be best to investigate the situation prior to suppressing the warnings.

Revision history for this message
Jeff Hill (johill-lanl) wrote :

The "insecure" fuctions were very numerous. Microsoft has new versions with an _s at the end to denote their new "secure" versions. It is probably not foolish, but some thought should go into deciding to use these functions. I have not investigated the new functions in depth, yet. In any event, it would be cumbersome to convert and give rise to more messy stuff like the EpicsShareAPI.

     The Posix deprecations in base were the ones in the email, some repeated, perhaps a dozen. This is foolishness IMHO. MEDM, etc. have the same problem.

     Places like Python, XEmacs, etc. that use lots of UNIX functions seem to be using the two defines mentioned. The alternative is to have warnings or rename all the functions for WIN32. Neither option is attractive.

     In regard to /Ehsc, I checked that MSVC 7.1 accepts that. I have uninstalled 7.0 and previous, so I didn't check them. In any event, 7.1 is 4 or 5 years old, so I don't think supporting 6 is necessary. If you have these versions, you can type "cl -help" to see.

>> The problem here might be my using #include of ANSI C header files
>> where
C++
>> header files could be used.

     I doubt that is the problem.

     The builds of base, MEDM, and others I have checked are clean with these defines. (As clean as they were before, anyway.)

Revision history for this message
Andrew Johnson (anj) wrote :

Is this issue still open? It looks from the above notes like it has been resolved with the two defines.

Revision history for this message
Jeff Hill (johill-lanl) wrote :

Fixed in R3.14.9

Revision history for this message
Andrew Johnson (anj) wrote :

R3.14.9 Released.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.