I have a simple C++ with Boost like this:
#include
int main()
{
std::string latlonStr = \"hello,ergr()()rg(rg)\";
boo
You can also disable this warning in specific headers:
#if defined(_MSC_VER) && _MSC_VER >= 1400
#pragma warning(push)
#pragma warning(disable:4996)
#endif
/* your code */
#if defined(_MSC_VER) && _MSC_VER >= 1400
#pragma warning(pop)
#endif
It is nothing to worry about. In the last few releases of MSVC, they've gone into full security-paranoia mode. std::copy
issues this warning when it is used with raw pointers, because when used incorrectly, it can result in buffer overflows.
Their iterator implementation performs bounds checking to ensure this doesn't happen, at a significant performance cost.
So feel free to ignore the warning. It doesn't mean there's anything wrong with your code. It is just saying that if there is something wrong with your code, then bad things will happen. Which is an odd thing to issue warnings about. ;)
The warning comes from Visual Studio's non-standard "safe" library checks introduced starting with MSVC 8.0. Microsoft has identified "potentially dangerous" APIs and has injected warnings discouraging their use. While it is technically possible to call std::copy in an unsafe way, 1) receiving this warning does not mean you are doing so, and 2) using std::copy as you normally should is not dangerous.
Alternatively, if you use C++11 and don't want to turn off warnings, you have the painful option of replacing
boost::is_any_of(L"(,)")
with the following lambda expression
[](wchar_t &c) { for (auto candidate : { L'(', L',', L')' }) { if (c == candidate) return true; }; return false; }
You can also possibly pack that into a macro
Go to the properties of your C++ project
Expand the "C/C++"
Advanced: Disable Specific Warnings: 4996
If you feel safe about disabling this error:
" -D_SCL_SECURE_NO_WARNINGS"