2012-03-11 5 views
1

dleimiter에서 문자열을 분할하는 함수가 필요하며 boost 라이브러리를 사용하여 boost :: split을 시도했습니다. 그것은 작동하지만, 그것은 나에게 많은 경고를 주며, 나는 이유를 알고 싶다.왜 boost :: split()을 호출하면 많은 경고가 발생합니까?

MSVC에서 경고를 생성 ++ 10 다음 단순화 코드 :

#include <tchar.h> 
#include <iostream> 
#include <string> 
#include <vector> 
#include <boost/algorithm/string.hpp> 

int _tmain(int argc, _TCHAR* argv[]) 
{ 
    std::vector<std::string> split_vector; 
    boost::split(split_vector, "string,to,split", boost::is_any_of(",")); 
    for(size_t i=0;i<split_vector.size();i++) { 
     std::cout << split_vector[i] << "\n"; 
    } 
} 

이 경고의 약 100 라인이며, 여기 스크롤/접을 수있는 물건을 만드는 방법을 알고하지 않습니다,하지만 그들은이다 모두 같음 :

c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility(2227): warning C4996: 'std::_Copy_impl': 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' 
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility(2212) : see declaration of 'std::_Copy_impl' 
c:\program files\boost\boost_1_49_0\boost\algorithm\string\detail\classification.hpp(102) : see reference to function template instantiation '_OutIt std::copy<const char*,char*>(_InIt,_InIt,_OutIt)' being compiled 
with 
[ 
    _OutIt=char *, 
    _InIt=const char * 
] 
c:\program files\boost\boost_1_49_0\boost\algorithm\string\classification.hpp(206) : see reference to function template instantiation 'boost::algorithm::detail::is_any_ofF<CharT>::is_any_ofF<boost::iterator_range<IteratorT>>(const RangeT &)' being compiled 
with 
[ 
    CharT=char, 
    IteratorT=const char *, 
    RangeT=boost::iterator_range<const char *> 
] 
c:\users\administrator\documents\visual studio 2010\projects\cas testing\tests\tests.cpp(10) : see reference to function template instantiation 'boost::algorithm::detail::is_any_ofF<CharT> boost::algorithm::is_any_of<const char[2]>(RangeT (&))' being compiled 
with 
[ 
    CharT=char, 
    RangeT=const char [2] 
] 

등등.

누구에게 무슨 일이 일어나고 있는지 알고 계십니까?

+0

[C++ 부스트 :이 경고의 원인은 무엇입니까?] (http://stackoverflow.com/questions/1301277/c-boost-whats-the-cause-of-this-warning) – Bart

+0

컴파일됩니다. ideone에 대한 경고없이 : http://ideone.com/LnNJA – Nawaz

+1

@ Nawaz VS와 마찬가지로 잘 작동 할 것입니다. 그들은 지나치게 보호받는 경고를 가지고 있습니다. 내가 속한 가능한 속임수를 보라. (Ps.는 부스트를 지원하는 이데온을 알지 못했습니다.) – Bart

답변

1

경고의 첫 번째 줄은 모든 이유와 이유를 피할 수있는 방법을 알려줍니다.이 경고를 비활성화하려면 -D_SCL_SECURE_NO_WARNINGS를 사용하십시오. 따라서 프로젝트 속성으로 가서 _SCL_SECURE_NO_WARNINGS를 미리 정의 된 매크로에 넣으십시오.

+0

감사합니다. 경고를 사용 중지하기 전에 실제로 아무 것도 잘못하지 않았는지 확인하고 싶었습니다. 프로젝트의 명령 행 옵션에 -D_SCL_SECURE_NO_WARNINGS를두기 만하면 사용할 수 없지만 매크로로 _SCL_SECURE_NO_WARNINGS를 선언해도 작동합니다. –

관련 문제