[boost.asio] Timer.5 example code: 8 compiling errors

Hi there, When compiling the example program "Timer.5 - Synchronising handlers in multithreaded programs" of boost asio 1_44 with MSVC 2008 professional on Window XP professional, I got 8 compiling errors, although the code executes without any problem. Is it safe to ignore those warnings? BTW: the Boost 1_44 was installed on my machine with the Binary Installers recommended in boost documentation. Thanks, Robert ------- Compiling warnings I got ---------- 1>------ Rebuild All started: Project: 4_strand_multithreaded, Configuration: Debug Win32 ------ 1>Deleting intermediate and output files for project '4_strand_multithreaded', configuration 'Debug|Win32' 1>Compiling... 1>4_strand_multithreaded.cpp 1>Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example: 1>- add -D_WIN32_WINNT=0x0501 to the compiler command line; or 1>- add _WIN32_WINNT=0x0501 to your project's Preprocessor Definitions. 1>Assuming _WIN32_WINNT=0x0501 (i.e. Windows XP target). 1>c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(589) : warning C4996: 'std::_Traits_helper::copy_s': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' 1> c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(604) : see declaration of 'std::_Traits_helper::copy_s' 1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(1057) : see reference to function template instantiation 'char *std::_Traits_helper::copy_s<_Traits>(char *,size_t,const char *,size_t)' being compiled 1> with 1> [ 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(1046) : while compiling class template member function 'std::basic_string<_Elem,_Traits> &std::basic_string<_Elem,_Traits>::assign(const std::basic_string<_Elem,_Traits> &,unsigned int,unsigned int)' 1> with 1> [ 1> _Elem=char, 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1> c:\program files\boost\boost_1_44\boost\token_functions.hpp(520) : see reference to class template instantiation 'std::basic_string<_Elem,_Traits>' being compiled 1> with 1> [ 1> _Elem=char, 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1> c:\program files\boost\boost_1_44\boost\tokenizer.hpp(92) : see reference to class template instantiation 'boost::char_separator<Char,Tr>' being compiled 1> with 1> [ 1> Char=char, 1> Tr=traits_type 1> ] 1> c:\program files\boost\boost_1_44\boost\date_time\date_parsing.hpp(127) : see reference to class template instantiation 'boost::tokenizer<TokenizerFunc,Iterator,Type>' being compiled 1> with 1> [ 1> TokenizerFunc=char_separator_type, 1> Iterator=std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>>, 1> Type=std::basic_string<char,std::char_traits<char>,std::allocator<char>> 1> ] 1> c:\program files\boost\boost_1_44\boost\date_time\gregorian\parsers.hpp(30) : see reference to function template instantiation 'date_type boost::date_time::parse_date<boost::gregorian::date>(const std::string &,int)' being compiled 1> with 1> [ 1> date_type=boost::gregorian::date 1> ] 1>c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(589) : warning C4996: 'std::_Traits_helper::copy_s': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' 1> c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(604) : see declaration of 'std::_Traits_helper::copy_s' 1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(2155) : see reference to function template instantiation 'wchar_t *std::_Traits_helper::copy_s<_Traits>(wchar_t *,size_t,const wchar_t *,size_t)' being compiled 1> with 1> [ 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(2148) : while compiling class template member function 'void std::basic_string<_Elem,_Traits>::_Tidy(bool,unsigned int)' 1> with 1> [ 1> _Elem=wchar_t, 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1> c:\program files\boost\boost_1_44\boost\token_functions.hpp(520) : see reference to class template instantiation 'std::basic_string<_Elem,_Traits>' being compiled 1> with 1> [ 1> _Elem=wchar_t, 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1> c:\program files\boost\boost_1_44\boost\date_time\date_parsing.hpp(294) : see reference to class template instantiation 'boost::char_separator<Char,Tr>' being compiled 1> with 1> [ 1> Char=wchar_t, 1> Tr=traits_type 1> ] 1> c:\program files\boost\boost_1_44\boost\date_time\gregorian\parsers.hpp(84) : see reference to function template instantiation 'boost::date_time::period<point_rep,duration_rep> boost::date_time::from_simple_string_type<boost::gregorian::date,wchar_t>(const std::basic_string<_Elem,_Traits,_Ax> &)' being compiled 1> with 1> [ 1> point_rep=boost::gregorian::date, 1> duration_rep=boost::gregorian::date_duration, 1> _Elem=wchar_t, 1> _Traits=std::char_traits<wchar_t>, 1> _Ax=std::allocator<wchar_t> 1> ] 1>c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(616) : warning C4996: 'std::_Traits_helper::move_s': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' 1> c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(631) : see declaration of 'std::_Traits_helper::move_s' 1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(1270) : see reference to function template instantiation 'char *std::_Traits_helper::move_s<_Traits>(char *,size_t,const char *,size_t)' being compiled 1> with 1> [ 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(1262) : while compiling class template member function 'std::basic_string<_Elem,_Traits> &std::basic_string<_Elem,_Traits>::erase(unsigned int,unsigned int)' 1> with 1> [ 1> _Elem=char, 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1>c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(616) : warning C4996: 'std::_Traits_helper::move_s': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' 1> c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(631) : see declaration of 'std::_Traits_helper::move_s' 1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(1270) : see reference to function template instantiation 'wchar_t *std::_Traits_helper::move_s<_Traits>(wchar_t *,size_t,const wchar_t *,size_t)' being compiled 1> with 1> [ 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(1262) : while compiling class template member function 'std::basic_string<_Elem,_Traits> &std::basic_string<_Elem,_Traits>::erase(unsigned int,unsigned int)' 1> with 1> [ 1> _Elem=wchar_t, 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1>c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(607) : warning C4996: 'std::char_traits<char>::copy': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' 1> c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(453) : see declaration of 'std::char_traits<char>::copy' 1> c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(589) : see reference to function template instantiation 'char *std::_Traits_helper::copy_s<_Traits>(char *,size_t,const char *,size_t,std::_Unsecure_char_traits_tag)' being compiled 1> with 1> [ 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(1057) : see reference to function template instantiation 'char *std::_Traits_helper::copy_s<_Traits>(char *,size_t,const char *,size_t)' being compiled 1> with 1> [ 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1>c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(607) : warning C4996: 'std::char_traits<wchar_t>::copy': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' 1> c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(338) : see declaration of 'std::char_traits<wchar_t>::copy' 1> c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(589) : see reference to function template instantiation 'wchar_t *std::_Traits_helper::copy_s<_Traits>(wchar_t *,size_t,const wchar_t *,size_t,std::_Unsecure_char_traits_tag)' being compiled 1> with 1> [ 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(2155) : see reference to function template instantiation 'wchar_t *std::_Traits_helper::copy_s<_Traits>(wchar_t *,size_t,const wchar_t *,size_t)' being compiled 1> with 1> [ 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1>c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(634) : warning C4996: 'std::char_traits<char>::move': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' 1> c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(477) : see declaration of 'std::char_traits<char>::move' 1> c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(616) : see reference to function template instantiation 'char *std::_Traits_helper::move_s<_Traits>(char *,size_t,const char *,size_t,std::_Unsecure_char_traits_tag)' being compiled 1> with 1> [ 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(1270) : see reference to function template instantiation 'char *std::_Traits_helper::move_s<_Traits>(char *,size_t,const char *,size_t)' being compiled 1> with 1> [ 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1>c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(634) : warning C4996: 'std::char_traits<wchar_t>::move': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' 1> c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(362) : see declaration of 'std::char_traits<wchar_t>::move' 1> c:\program files\microsoft visual studio 9.0\vc\include\iosfwd(616) : see reference to function template instantiation 'wchar_t *std::_Traits_helper::move_s<_Traits>(wchar_t *,size_t,const wchar_t *,size_t,std::_Unsecure_char_traits_tag)' being compiled 1> with 1> [ 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(1270) : see reference to function template instantiation 'wchar_t *std::_Traits_helper::move_s<_Traits>(wchar_t *,size_t,const wchar_t *,size_t)' being compiled 1> with 1> [ 1> _Traits=boost::tokenizer_detail::traits_extension<traits_type> 1> ] 1>Compiling manifest to resources... 1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0 1>Copyright (C) Microsoft Corporation. All rights reserved. 1>Linking... 1>LINK : C:\UTM_Coding\Boost_Asio\ASIO_Projects\5_timer_5_strand_multithreaded\Debug\4_strand_multithreaded.exe not found or not built by the last incremental link; performing full link 1>Embedding manifest... 1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0 1>Copyright (C) Microsoft Corporation. All rights reserved. 1>Build log was saved at " file://c:\5_timer_5_strand_multithreaded\4_strand_multithreaded\Debug\BuildLog.htm<file:///c:/5_timer_5_strand_multithreaded/4_strand_multithreaded/Debug/BuildLog.htm> " 1>4_strand_multithreaded - 0 error(s), 8 warning(s) ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

When compiling the example program "Timer.5 - Synchronising handlers in multithreaded programs" of boost asio 1_44 with MSVC 2008 professional on Window XP professional, I got 8 compiling errors, although the code executes without any problem.
Compiler errors mean that the compilation failed. What you get is just compiler *warnings*. To suppress these warnings, compile with #define _SCL_SECURE_NO_WARNINGS

Hi there, Thanks for your reply. I added it to my code and now the include part looks as follows: #include <iostream> #include <boost/asio.hpp> #include <boost/thread.hpp> #include <boost/bind.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #define _SCL_SECURE_NO_WARNINGS But I still got those 8 warnings. Any further suggestions? Regards, Robert On Sat, Dec 25, 2010 at 11:13 AM, Igor R <boost.lists@gmail.com> wrote:
When compiling the example program "Timer.5 - Synchronising handlers in multithreaded programs" of boost asio 1_44 with MSVC 2008 professional on Window XP professional, I got 8 compiling errors, although the code executes without any problem.
Compiler errors mean that the compilation failed. What you get is just compiler *warnings*. To suppress these warnings, compile with #define _SCL_SECURE_NO_WARNINGS _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Thanks for your reply. I added it to my code and now the include part looks as follows: #include <iostream> #include <boost/asio.hpp> #include <boost/thread.hpp> #include <boost/bind.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #define _SCL_SECURE_NO_WARNINGS But I still got those 8 warnings. Any further suggestions?
Define that *before* including the headers. Or even better - in the global preprocessor definitions of your project.
participants (2)
-
Boost lzw
-
Igor R