Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2008-04-05 12:12:28


Mat Marcus wrote:
> Hi Beman,
>
> error_code.cpp contains the following #defines:
>
> #define _CRT_SECURE_NO_DEPRECATE
> #define _SCL_SECURE_NO_DEPRECATE
>
> It should first check that these macros are not defined already.
> Otherwise users who #define these macros on the command line will
> received duplicate definition errors, as I am. Also, you might
> consider adding:
>
> #define _SECURE_SCL 0
>
> for VC 9.

Leaving aside the _SECURE_SCL 0 question, I think we need a boost header
file that wraps up the needed code. This header should not be included
in Boost headers, since doing so gets in user's way. But it would be
useful in library sources like error_code.cpp and test programs.

Building on Hartmut's suggestion, the header might look like this:

//
// silence 'secure' and 'deprecate' warnings
//
#if (_MSC_VER >= 1400) && !defined(BOOST_ENABLE_DEPRECATE_WARNINGS)
# ifndef _CRT_SECURE_NO_DEPRECATE
# define _CRT_SECURE_NO_DEPRECATE
# endif
# ifndef _SCL_SECURE_NO_DEPRECATE
# define _SCL_SECURE_NO_DEPRECATE
# endif
#endif

#if (_MSC_VER >= 1400) && !defined(BOOST_ENABLE_SECURE_WARNINGS)
# ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
# endif
# ifndef _SCL_SECURE_NO_WARNINGS
# define _SCL_SECURE_NO_WARNINGS
# endif
#endif

Perhaps name it <boost/config/silence_misfeatures.hpp> or similar. I
don't want a Microsoft specific name since it might be useful later for
other compiler misfeatures.

I'd add a comment explaining not to use it in user-visible code like
boost/ headers.

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk