[CMake] Re: [vtk-developers] deprecated CRT routines in MSVS8

Brad King brad.king at kitware.com
Wed Aug 3 13:35:14 EDT 2005


Yianis Nikolaou wrote:
> I have to agree with Amitha because
> IMHO the activation/deactivation of these warnings
> should be left for the developer to decide explicitly,
> and this can be handled easily with the addition of a line like
> 
> ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
> in the CMakeList.txt file.

The problem with this approach is that there are something like 10 
different macros that need to be defined to "fix" everything:

_CRT_FAR_MAPPINGS_NO_DEPRECATE
_CRT_IS_WCTYPE_NO_DEPRECATE
_CRT_MANAGED_FP_NO_DEPRECATE
_CRT_NONSTDC_NO_DEPRECATE
_CRT_SECURE_NO_DEPRECATE
_CRT_SECURE_NO_DEPRECATE_GLOBALS
_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
_CRT_TIME_FUNCTIONS_NO_DEPRECATE
_CRT_VCCLRIT_NO_DEPRECATE
_SCL_SECURE_NO_DEPRECATE

although some of these probably shouldn't be defined.  Most projects 
will probably define at least _CRT_SECURE_NO_DEPRECATE and 
_SCL_SECURE_NO_DEPRECATE.  We could define a CMake variable like

SET(CMAKE_MSVC_NO_DEPRECATE_LIST
   _CRT_SECURE_NO_DEPRECATE
   _SCL_SECURE_NO_DEPRECATE
   # ...
   )

that is used by the generator to add the desired set of definitions. 
The common list would be the default.  Then projects that want the 
deprecation could change the list or set it to empty:

SET(CMAKE_MSVC_NO_DEPRECATE_LIST)

In this way CMake helps provide a cross-platform "standard" C and C++ 
implementation.

> or by
>  #  pragma warning ( disable : 4996 ) /* depreciated functions */
> in a header file as Goodwin suggested.

This solution is not a good idea because it disables deprecation 
warnings for ALL functions/methods, not just the CRT ones.  For many 
projects these warnings should remain on.

-Brad



More information about the vtk-developers mailing list