2017-10-10 2 views
0

우선 부스트 라이브러리를 사용하고 변경된 사항이 있으면 Windows 시스템에서 코드가 컴파일됩니다. 코드 자체에는 행렬에 작용하는 많은 함수가 있지만이 함수 만 오류를 트리거합니다. 같은에 {001 010} : 글쎄, 내가 좋아하는 행렬을 변환하려고 {1 2} 그러나 이상하게도 나는 내 코드를 컴파일 할 수 없습니다 나는 오류를 찾을 수 없습니다 누군가가 나를 도울 수 있으면 기뻐할 것입니다. 코드 아래 : 오류를 찾기 위해 노력C++ 입력을 클래스로 변환 할 때 부스트 매트릭스 오류가 발생했습니다.

1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xutility(2372): error C4996: 'std::copy::_Unchecked_iterators::_Deprecate': Call to 'std::copy' 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 (x86)\microsoft visual studio 14.0\vc\include\xutility(2372): note: see declaration of 'std::copy::_Unchecked_iterators::_Deprecate' 
1> e:\c++ libraries\general\boost_1_65_0\boost\numeric\ublas\storage.hpp(204): note: see reference to function template instantiation '_OutIt *std::copy<float*,float*>(_InIt,_InIt,_OutIt)' being compiled 
1>   with 
1>   [ 
1>    _OutIt=float *, 
1>    _InIt=float * 
1>   ] 
1> e:\c++ libraries\general\boost_1_65_0\boost\numeric\ublas\storage.hpp(201): note: while compiling class template member function 'boost::numeric::ublas::unbounded_array<float,std::allocator<T>> &boost::numeric::ublas::unbounded_array<T,std::allocator<T>>::operator =(const boost::numeric::ublas::unbounded_array<T,std::allocator<T>> &)' 
1>   with 
1>   [ 
1>    T=float 
1>   ] 
1> e:\c++ libraries\general\boost_1_65_0\boost\numeric\ublas\matrix.hpp(310): note: see reference to function template instantiation 'boost::numeric::ublas::unbounded_array<float,std::allocator<T>> &boost::numeric::ublas::unbounded_array<T,std::allocator<T>>::operator =(const boost::numeric::ublas::unbounded_array<T,std::allocator<T>> &)' being compiled 
1>   with 
1>   [ 
1>    T=float 
1>   ] 
1> e:\c++ libraries\general\boost_1_65_0\boost\numeric\ublas\matrix.hpp(102): note: see reference to class template instantiation 'boost::numeric::ublas::unbounded_array<float,std::allocator<T>>' being compiled 
1>   with 
1>   [ 
1>    T=float 
1>   ] 
1> g:\c++ python\travail\visualstudio\visualstudio\guigui\neural net\neural net\utils.hpp(21): note: see reference to class template instantiation 'boost::numeric::ublas::matrix<float,boost::numeric::ublas::row_major,boost::numeric::ublas::unbounded_array<float,std::allocator<T>>>' being compiled 
1>   with 
1>   [ 
1>    T=float 
1>   ] 
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xmemory(102): error C4996: 'std::uninitialized_copy::_Unchecked_iterators::_Deprecate': Call to 'std::uninitialized_copy' 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 (x86)\microsoft visual studio 14.0\vc\include\xmemory(102): note: see declaration of 'std::uninitialized_copy::_Unchecked_iterators::_Deprecate' 
1> e:\c++ libraries\general\boost_1_65_0\boost\numeric\ublas\storage.hpp(94): note: see reference to function template instantiation '_FwdIt *std::uninitialized_copy<const float*,float*>(_InIt,_InIt,_FwdIt)' being compiled 
1>   with 
1>   [ 
1>    _FwdIt=float *, 
1>    _InIt=const float * 
1>   ] 
1> e:\c++ libraries\general\boost_1_65_0\boost\numeric\ublas\storage.hpp(89): note: while compiling class template member function 'boost::numeric::ublas::unbounded_array<float,std::allocator<T>>::unbounded_array(const boost::numeric::ublas::unbounded_array<T,std::allocator<T>> &)' 
1>   with 
1>   [ 
1>    T=float 
1>   ] 
1> e:\c++ libraries\general\boost_1_65_0\boost\numeric\ublas\matrix.hpp(162): note: see reference to function template instantiation 'boost::numeric::ublas::unbounded_array<float,std::allocator<T>>::unbounded_array(const boost::numeric::ublas::unbounded_array<T,std::allocator<T>> &)' being compiled 
1>   with 
1>   [ 
1>    T=float 
1>   ] 
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

위의 기능에 저를 제공합니다 :

using namespace boost::numeric::ublas; 

typedef matrix <float, row_major, unbounded_array<float>> MATRIXf; 
MATRIXf matrix_to_class (const MATRIXf inputM) 
{ 
    MATRIXf output; 
    for (std::size_t line = 0; line < inputM.size1(); line++) 
    {               
     for (std::size_t column = 0; column < inputM.size2(); column++) 
     {              
      if (column == 1)            
      {             
       output.insert_element(line,0.0,column); 
      }             
     }              
    } 

    return output; 
}  

다음은 오류 코드입니다. 미리 감사드립니다.

답변

1

첫 번째 오류 메시지의 끝 부분에는 "이 경고를 사용하지 않으려면 -D_SCL_SECURE_NO_WARNINGS를 사용하십시오"라는 텍스트가 있습니다. https://msdn.microsoft.com/en-us/library/ttcz0bys.aspx에는 경고 및 반복기에 대한 자세한 설명이 있습니다. 본질적으로 Microsoft는 개발자가 잘못된 반복자 사용을 방지 할 수 있도록 표준 C++ 함수의 "안전한"변형을 만들었습니다. 오류 메시지는 _SCL_SECURE_NO_WARNINGS를 정의 할 것을 제안합니다. 이 작업은 C/C++/Preprocessor/Preprocessor Definitions 프로젝트 속성에서 수행 할 수 있습니다. 과거에 작업 한 프로젝트에서 성능에 치명적인 영향을 미쳐 기능의 "안전한"버전을 모두 비활성화했습니다.

위의 Microsoft 페이지에서 반복기에 대한 자세한 내용을 확인하십시오.

관련 문제