2012-01-20 3 views
-4

대학의 Fedora 버전 (Linux version 3.1.9-1.fc16.x86_64 ([email protected]) (gcc version 4.6.2 20111027 (Red Hat 4.6.2-1) (GCC)))에서 컴파일하기 위해 VS2010의 가정용 사본에 작성된 프로그램을 얻으려고합니다.
이 프로그램은 자동 유형 및 이동 생성자와 같은 다양한 C++ 11 기능을 사용합니다.
이 모두 VS2010에는 문제가 작동하지 않습니다,하지만 난 리눅스 (g++ -g -Wall -std=c++0x -pedantic을)에 컴파일 할 때, 나는 오류의 다음과 같은 회전 수 :지도/Map.h 이후g ++에서 std :: vectors로 이동 구문 사용하기

In file included from /usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/vector:63:0, 
       from src/OpenGL/Renderer.h:4, 
       from src/Wolfenstein3D2011.cpp:2: 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_construct.h: In function ‘void std::_Construct(_T1*, _Args&& ...) [with _T1 = Wulf::MapWall, _Args = {const Wulf::MapWall&}]’: 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_uninitialized.h:77:3: instantiated from ‘static _ForwardIterator std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const Wulf::MapWall*, std::vector<Wulf::MapWall> >, _ForwardIterator = Wulf::MapWall*, bool _TrivialValueTypes = false]’ 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_uninitialized.h:119:41: instantiated from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const Wulf::MapWall*, std::vector<Wulf::MapWall> >, _ForwardIterator = Wulf::MapWall*]’ 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_uninitialized.h:259:63: instantiated from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const Wulf::MapWall*, std::vector<Wulf::MapWall> >, _ForwardIterator = Wulf::MapWall*, _Tp = Wulf::MapWall]’ 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_vector.h:280:9: instantiated from ‘std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = Wulf::MapWall, _Alloc = std::allocator<Wulf::MapWall>, std::vector<_Tp, _Alloc> = std::vector<Wulf::MapWall>]’ 
src/Map/Map.h:17:8: instantiated from here 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_construct.h:76:7: error: no matching function for call to ‘Wulf::MapWall::MapWall(const Wulf::MapWall&)’ 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_construct.h:76:7: note: candidates are: 
src/Map/MapWall.h:18:3: note: Wulf::MapWall::MapWall(Wulf::MapWall&&) 
src/Map/MapWall.h:18:3: note: no known conversion for argument 1 from ‘const Wulf::MapWall’ to ‘Wulf::MapWall&&’ 
src/Map/MapWall.h:12:3: note: Wulf::MapWall::MapWall(Wulf::Direction) 
src/Map/MapWall.h:12:3: note: no known conversion for argument 1 from ‘const Wulf::MapWall’ to ‘Wulf::Direction’ 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_construct.h: In function ‘void std::_Construct(_T1*, _Args&& ...) [with _T1 = Wulf::MapNode, _Args = {const Wulf::MapNode&}]’: 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_uninitialized.h:77:3: instantiated from ‘static _ForwardIterator std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const Wulf::MapNode*, std::vector<Wulf::MapNode> >, _ForwardIterator = Wulf::MapNode*, bool _TrivialValueTypes = false]’ 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_uninitialized.h:119:41: instantiated from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const Wulf::MapNode*, std::vector<Wulf::MapNode> >, _ForwardIterator = Wulf::MapNode*]’ 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_uninitialized.h:259:63: instantiated from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const Wulf::MapNode*, std::vector<Wulf::MapNode> >, _ForwardIterator = Wulf::MapNode*, _Tp = Wulf::MapNode]’ 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_vector.h:280:9: instantiated from ‘std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = Wulf::MapNode, _Alloc = std::allocator<Wulf::MapNode>, std::vector<_Tp, _Alloc> = std::vector<Wulf::MapNode>]’ 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_construct.h:76:7: instantiated from ‘void std::_Construct(_T1*, _Args&& ...) [with _T1 = std::vector<Wulf::MapNode>, _Args = {const std::vector<Wulf::MapNode>&}]’ 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_uninitialized.h:77:3: instantiated from ‘static _ForwardIterator std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::vector<Wulf::MapNode>*, std::vector<std::vector<Wulf::MapNode> > >, _ForwardIterator = std::vector<Wulf::MapNode>*, bool _TrivialValueTypes = false]’ 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_uninitialized.h:119:41: instantiated from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::vector<Wulf::MapNode>*, std::vector<std::vector<Wulf::MapNode> > >, _ForwardIterator = std::vector<Wulf::MapNode>*]’ 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_uninitialized.h:259:63: instantiated from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::vector<Wulf::MapNode>*, std::vector<std::vector<Wulf::MapNode> > >, _ForwardIterator = std::vector<Wulf::MapNode>*, _Tp = std::vector<Wulf::MapNode>]’ 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_vector.h:280:9: instantiated from ‘std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<Wulf::MapNode>, _Alloc = std::allocator<std::vector<Wulf::MapNode> >, std::vector<_Tp, _Alloc> = std::vector<std::vector<Wulf::MapNode> >]’ 
src/Map/Map.h:17:8: instantiated from here 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_construct.h:76:7: error: no matching function for call to ‘Wulf::MapNode::MapNode(const Wulf::MapNode&)’ 
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_construct.h:76:7: note: candidates are: 
src/Map/MapNode.h:15:3: note: Wulf::MapNode::MapNode(Wulf::MapNode&&) 
src/Map/MapNode.h:15:3: note: no known conversion for argument 1 from ‘const Wulf::MapNode’ to ‘Wulf::MapNode&&’ 
src/Map/MapNode.h:10:3: note: Wulf::MapNode::MapNode(Wulf::coord, Wulf::coord, Wulf::word, Wulf::word) 
src/Map/MapNode.h:10:3: note: candidate expects 4 arguments, 1 provided 
make: *** [obj/main.o] Error 1 

: 17 내가했습니다, class Map {입니다 무슨 일이 일어나고 있는지 전혀 몰랐어. 나는이 원인으로 상상할 수
유일한 라인은지도/Map.cpp에 분명히
nodes[x].push_back(MapNode(x - halfwidth, y - halfheight, map[i], objs[i]));

walls.push_back(MapWall(air ? DIRECTION_WEST : DIRECTION_EAST));
VS2010에서 이러한 작업 벌금, 성공적으로 벡터로 임시 이동 모두, 그러나 아니다 g ++에서.
이 컴파일러의 기발한 일입니까, 아니면 내가 잘못한 것입니까? 해당 메시지를보고

+3

"크리스탈 볼 경기에는 규칙이 없습니다." "아니, 거기에 * 하나의 규칙 : 수정 구슬 가져와." –

+0

게시 한 행 (walls.push_back ...)으로 인해 발생하는 것은 아닙니다. 컴파일러는'MapNodes'의 벡터 벡터를 복사하지 못했다고 말합니다. 코드의 어딘가에서 찾으십시오. 어쩌면 map :: map (const map &)'이 필요하고, 그런 멤버가 있습니다. – jpalecek

+0

일부 코드 (최소한의?)를 재현하면 좋은 대답을 얻을 가능성이 더 큽니다. MapNode와 MapWall을 게시 할 수 있습니까? 이동 생성자가 있습니까? –

답변

3

는 지금까지 내가 오류 메시지에서 말할 수있는, 당신은 vector<MapWall>를 포함하는 Map을 복사하려고하고 MapWall가 복사 가능한 아니기 때문에이 실패합니다.

이러한 유형을 복사 할 수 있다고 가정하면 복사 생성자를 MapWall에 추가해야합니다. 사용자가 선언 한 이동 생성자는 암시 적으로 생성되지 않는다는 것을 의미합니다. (나는 VS2010이 잘못 생성 한 것 같아서 코드가 왜 작동하는지 설명 할 것입니다.)

그렇지 않은 경우 비공개 삭제 된 복사본 생성자를 Map에 추가하면 더 쉽게 불량 복사본 작업을 추적 할 수 있습니다. 그러면 복사 대상을 정확히 보여주는 오류 메시지가 표시됩니다.

+0

'Map'에는 복사 생성자가 없으므로 솔직히 저에게는 발생하지 않았지만 여러분은 옳았습니다. 함수 중 하나가 참조 대신 값으로 Map을 전달하고있었습니다. –

1

, 나는 확신 그것은 당신의 잘못, 그리고 VS2010는

이 너무 permisive 인 :

src/Map/MapNode.h:15:3: note: Wulf::MapNode::MapNode(Wulf::MapNode&&) 
src/Map/MapNode.h:15:3: note: no known conversion for argument 1 from ‘const Wulf::MapNode’ to ‘Wulf::MapNode&&’ 
src/Map/MapNode.h:10:3: note: Wulf::MapNode::MapNode(Wulf::coord, Wulf::coord, Wulf::word, Wulf::word) 

당신이 이동 생성자, 또는 실제 생성자에 lreference의 개체를 전달하려한다는 것을 의미 .

같은 오류는 다음과 같습니다

no known conversion for argument 1 from ‘const Wulf::MapWall’ to ‘Wulf::MapWall&&’ 

몇 가지 코드를 보지 않고, 정확히 당신이 무슨 짓을했는지 알 수 없습니다.

관련 문제