2017-10-29 17 views
0

최근에 gcc 5.4에서 gcc 6.3으로 업그레이드되었습니다. 컴파일 및 실행에 사용 된 C++ 코드는 컴파일이 중단되어서 어떤 일이 발생했는지 추론 할만큼 충분히 경험이 없습니다.gcc 5.4에서 gcc 6.3으로 업그레이드 std :: thread std : ref issue

코드는 sfml을 사용하여 창을 생성하기 위해 만든 객체에 있습니다. sfml :: Window 포인터를 사용하는 스레드를 인스턴스화하여 외부에서 설정된 비디오 프레임에 대한 포인터를 기반으로 이미지를 업데이트합니다.

코드는 기본적이고 간단하며 코드의 다른 곳에서 스레드를 생성합니다 (객체의 스레드는 아님). 여기

코드 단편 같습니다 에러 (에러 출력 라인 (174)) 위의 renderThread = 라인 생성

class owindow 
{ 
public: 
    ... 
private: 
    ... 
    std::thread renderThread; 
    ... 
    void windowRender(void); 
    ... 
}; 

owindow::owindow(std::string name, win_t type, int width, int height, uint32_t *image) 
: renderThread() 
{ 
    typ = type; 
    wid = width; 
    hei = height; 
    nam = name; 
    frame = image; 
    resizewin = false; 
    killthread = false; 

    ... 
    window = new sf::Window(sf::VideoMode(windowwidth, windowheight), name.c_str(), sf::Style::Default, settings); 
    window->setVerticalSyncEnabled(false); 
    ... 

void owindow::start(void) 
{ 
    // Start the render thread. 
    renderThread = std::thread(&owindow::windowRender, this); 
} 

길고 잔인 및 I 익사 것 같은 솔직히 느낄 때 I 그들을 이해하려고 노력하십시오. 언제부터 C++에 튜플이 있습니까? LOL. 나는 직장에서 파이썬을 배우고 있으며, 결국 튜플이 무엇인지를 알게되고, 그 다음에는 이런 일이 발생합니다 ...

방금 ​​확인한 결과 gcc 5.4로 실행되었습니다.

여기에 오류가 있습니다. 이것은 처음 몇 가지 오류이며, 포럼을 스팸하지 않으려합니다.

/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple: In instantiation of 'static constexpr bool std::_TC<<anonymous>, _Elements>::_MoveConstructibleTuple() [with _UElements = {const std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>&}; bool <anonymous> = true; _Elements = {void (*)(int, camera*, int*, int*), int, camera*, int*, int*}]': 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:626:248: required by substitution of 'template<class ... _UElements, typename std::enable_if<(((std::_TC<(sizeof... (_UElements) == 1), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_NotSameTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_MoveConstructibleTuple<_UElements ...>()) && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_ImplicitlyMoveConvertibleTuple<_UElements ...>()) && (5ul >= 1)), bool>::type <anonymous> > constexpr std::tuple< <template-parameter-1-1> >::tuple(_UElements&& ...) [with _UElements = {const std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>&}; typename std::enable_if<(((std::_TC<(sizeof... (_UElements) == 1), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_NotSameTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_MoveConstructibleTuple<_UElements ...>()) && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_ImplicitlyMoveConvertibleTuple<_UElements ...>()) && (5ul >= 1)), bool>::type <anonymous> = <missing>]' 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/functional:1363:8: required from 'struct std::_Bind_simple<void (*(int, camera*, int*, int*))(int, camera*, int*, int*)>' 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/thread:136:55: required from 'std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (*)(int, camera*, int*, int*); _Args = {int&, camera*, int*&, int*&}]' 
/...snip.../ofunctions.hpp:3221:97: required from here 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:483:67: error: mismatched argument pack lengths while expanding 'std::is_constructible<_Elements, _UElements&&>' 
     return __and_<is_constructible<_Elements, _UElements&&>...>::value; 
                    ^~~~~ 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:484:1: error: body of constexpr function 'static constexpr bool std::_TC<<anonymous>, _Elements>::_MoveConstructibleTuple() [with _UElements = {const std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>&}; bool <anonymous> = true; _Elements = {void (*)(int, camera*, int*, int*), int, camera*, int*, int*}]' not a return-statement 
    } 
^ 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple: In instantiation of 'static constexpr bool std::_TC<<anonymous>, _Elements>::_ImplicitlyMoveConvertibleTuple() [with _UElements = {const std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>&}; bool <anonymous> = true; _Elements = {void (*)(int, camera*, int*, int*), int, camera*, int*, int*}]': 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:626:362: required by substitution of 'template<class ... _UElements, typename std::enable_if<(((std::_TC<(sizeof... (_UElements) == 1), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_NotSameTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_MoveConstructibleTuple<_UElements ...>()) && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_ImplicitlyMoveConvertibleTuple<_UElements ...>()) && (5ul >= 1)), bool>::type <anonymous> > constexpr std::tuple< <template-parameter-1-1> >::tuple(_UElements&& ...) [with _UElements = {const std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>&}; typename std::enable_if<(((std::_TC<(sizeof... (_UElements) == 1), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_NotSameTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_MoveConstructibleTuple<_UElements ...>()) && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_ImplicitlyMoveConvertibleTuple<_UElements ...>()) && (5ul >= 1)), bool>::type <anonymous> = <missing>]' 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/functional:1363:8: required from 'struct std::_Bind_simple<void (*(int, camera*, int*, int*))(int, camera*, int*, int*)>' 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/thread:136:55: required from 'std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (*)(int, camera*, int*, int*); _Args = {int&, camera*, int*&, int*&}]' 
/...snip.../ofunctions.hpp:3221:97: required from here 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:489:65: error: mismatched argument pack lengths while expanding 'std::is_convertible<_UElements&&, _Elements>' 
     return __and_<is_convertible<_UElements&&, _Elements>...>::value; 
                   ^~~~~ 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:490:1: error: body of constexpr function 'static constexpr bool std::_TC<<anonymous>, _Elements>::_ImplicitlyMoveConvertibleTuple() [with _UElements = {const std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>&}; bool <anonymous> = true; _Elements = {void (*)(int, camera*, int*, int*), int, camera*, int*, int*}]' not a return-statement 
    } 
^ 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple: In instantiation of 'static constexpr bool std::_TC<<anonymous>, _Elements>::_NonNestedTuple() [with _SrcTuple = const std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>&; bool <anonymous> = true; _Elements = {void (*)(int, camera*, int*, int*), int, camera*, int*, int*}]': 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:662:419: required by substitution of 'template<class ... _UElements, class _Dummy, typename std::enable_if<((std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_ConstructibleTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_ImplicitlyConvertibleTuple<_UElements ...>()) && std::_TC<(std::is_same<_Dummy, void>::value && (1ul == 1)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_NonNestedTuple<const tuple<_Elements ...>&>()), bool>::type <anonymous> > constexpr std::tuple< <template-parameter-1-1> >::tuple(const std::tuple<_Args1 ...>&) [with _UElements = {void (*)(int, camera*, int*, int*), int, camera*, int*, int*}; _Dummy = void; typename std::enable_if<((std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_ConstructibleTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_ImplicitlyConvertibleTuple<_UElements ...>()) && std::_TC<(std::is_same<_Dummy, void>::value && (1ul == 1)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_NonNestedTuple<const tuple<_Elements ...>&>()), bool>::type <anonymous> = <missing>]' 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/functional:1363:8: required from 'struct std::_Bind_simple<void (*(int, camera*, int*, int*))(int, camera*, int*, int*)>' 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/thread:136:55: required from 'std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (*)(int, camera*, int*, int*); _Args = {int&, camera*, int*&, int*&}]' 
/...snip.../ofunctions.hpp:3221:97: required from here 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:495:244: error: wrong number of template arguments (6, should be 2) 
     return __and_<__not_<is_same<tuple<_Elements...>, 
                                                                ^ 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/type_traits:1558:8: note: provided for 'template<class _From, class _To> struct std::is_convertible' 
    struct is_convertible 
     ^~~~~~~~~~~~~~ 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:502:1: error: body of constexpr function 'static constexpr bool std::_TC<<anonymous>, _Elements>::_NonNestedTuple() [with _SrcTuple = const std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>&; bool <anonymous> = true; _Elements = {void (*)(int, camera*, int*, int*), int, camera*, int*, int*}]' not a return-statement 
    } 
^ 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple: In instantiation of 'static constexpr bool std::_TC<<anonymous>, _Elements>::_MoveConstructibleTuple() [with _UElements = {std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>}; bool <anonymous> = true; _Elements = {void (*)(int, camera*, int*, int*), int, camera*, int*, int*}]': 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:626:248: required by substitution of 'template<class ... _UElements, typename std::enable_if<(((std::_TC<(sizeof... (_UElements) == 1), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_NotSameTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_MoveConstructibleTuple<_UElements ...>()) && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_ImplicitlyMoveConvertibleTuple<_UElements ...>()) && (5ul >= 1)), bool>::type <anonymous> > constexpr std::tuple< <template-parameter-1-1> >::tuple(_UElements&& ...) [with _UElements = {std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>}; typename std::enable_if<(((std::_TC<(sizeof... (_UElements) == 1), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_NotSameTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_MoveConstructibleTuple<_UElements ...>()) && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_ImplicitlyMoveConvertibleTuple<_UElements ...>()) && (5ul >= 1)), bool>::type <anonymous> = <missing>]' 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/functional:1363:8: required from 'struct std::_Bind_simple<void (*(int, camera*, int*, int*))(int, camera*, int*, int*)>' 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/thread:136:55: required from 'std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (*)(int, camera*, int*, int*); _Args = {int&, camera*, int*&, int*&}]' 
/...snip.../ofunctions.hpp:3221:97: required from here 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:483:67: error: mismatched argument pack lengths while expanding 'std::is_constructible<_Elements, _UElements&&>' 
     return __and_<is_constructible<_Elements, _UElements&&>...>::value; 
                    ^~~~~ 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:484:1: error: body of constexpr function 'static constexpr bool std::_TC<<anonymous>, _Elements>::_MoveConstructibleTuple() [with _UElements = {std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>}; bool <anonymous> = true; _Elements = {void (*)(int, camera*, int*, int*), int, camera*, int*, int*}]' not a return-statement 
    } 
^ 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple: In instantiation of 'static constexpr bool std::_TC<<anonymous>, _Elements>::_ImplicitlyMoveConvertibleTuple() [with _UElements = {std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>}; bool <anonymous> = true; _Elements = {void (*)(int, camera*, int*, int*), int, camera*, int*, int*}]': 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:626:362: required by substitution of 'template<class ... _UElements, typename std::enable_if<(((std::_TC<(sizeof... (_UElements) == 1), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_NotSameTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_MoveConstructibleTuple<_UElements ...>()) && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_ImplicitlyMoveConvertibleTuple<_UElements ...>()) && (5ul >= 1)), bool>::type <anonymous> > constexpr std::tuple< <template-parameter-1-1> >::tuple(_UElements&& ...) [with _UElements = {std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>}; typename std::enable_if<(((std::_TC<(sizeof... (_UElements) == 1), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_NotSameTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_MoveConstructibleTuple<_UElements ...>()) && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_ImplicitlyMoveConvertibleTuple<_UElements ...>()) && (5ul >= 1)), bool>::type <anonymous> = <missing>]' 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/functional:1363:8: required from 'struct std::_Bind_simple<void (*(int, camera*, int*, int*))(int, camera*, int*, int*)>' 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/thread:136:55: required from 'std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (*)(int, camera*, int*, int*); _Args = {int&, camera*, int*&, int*&}]' 
/...snip.../ofunctions.hpp:3221:97: required from here 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:489:65: error: mismatched argument pack lengths while expanding 'std::is_convertible<_UElements&&, _Elements>' 
     return __and_<is_convertible<_UElements&&, _Elements>...>::value; 
                   ^~~~~ 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:490:1: error: body of constexpr function 'static constexpr bool std::_TC<<anonymous>, _Elements>::_ImplicitlyMoveConvertibleTuple() [with _UElements = {std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>}; bool <anonymous> = true; _Elements = {void (*)(int, camera*, int*, int*), int, camera*, int*, int*}]' not a return-statement 
    } 
^ 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple: In instantiation of 'static constexpr bool std::_TC<<anonymous>, _Elements>::_NonNestedTuple() [with _SrcTuple = std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>&&; bool <anonymous> = true; _Elements = {void (*)(int, camera*, int*, int*), int, camera*, int*, int*}]': 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:686:422: required by substitution of 'template<class ... _UElements, class _Dummy, typename std::enable_if<((std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_MoveConstructibleTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_ImplicitlyMoveConvertibleTuple<_UElements ...>()) && std::_TC<(std::is_same<_Dummy, void>::value && (1ul == 1)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_NonNestedTuple<tuple<_Elements ...>&&>()), bool>::type <anonymous> > constexpr std::tuple< <template-parameter-1-1> >::tuple(std::tuple<_Args1 ...>&&) [with _UElements = {void (*)(int, camera*, int*, int*), int, camera*, int*, int*}; _Dummy = void; typename std::enable_if<((std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_MoveConstructibleTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_ImplicitlyMoveConvertibleTuple<_UElements ...>()) && std::_TC<(std::is_same<_Dummy, void>::value && (1ul == 1)), void (*)(int, camera*, int*, int*), int, camera*, int*, int*>::_NonNestedTuple<tuple<_Elements ...>&&>()), bool>::type <anonymous> = <missing>]' 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/functional:1363:8: required from 'struct std::_Bind_simple<void (*(int, camera*, int*, int*))(int, camera*, int*, int*)>' 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/thread:136:55: required from 'std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (*)(int, camera*, int*, int*); _Args = {int&, camera*, int*&, int*&}]' 
/...snip.../ofunctions.hpp:3221:97: required from here 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:495:244: error: wrong number of template arguments (6, should be 2) 
     return __and_<__not_<is_same<tuple<_Elements...>, 
                                                                ^ 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/type_traits:1558:8: note: provided for 'template<class _From, class _To> struct std::is_convertible' 
    struct is_convertible 
     ^~~~~~~~~~~~~~ 
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include/g++-v6/tuple:502:1: error: body of constexpr function 'static constexpr bool std::_TC<<anonymous>, _Elements>::_NonNestedTuple() [with _SrcTuple = std::tuple<void (*)(int, camera*, int*, int*), int, camera*, int*, int*>&&; bool <anonymous> = true; _Elements = {void (*)(int, camera*, int*, int*), int, camera*, int*, int*}]' not a return-statement 
    } 
^ 
CMake Error at ocapture_generated_ocapture.cu.o.cmake:282 (message): 
    Error generating file 
    /...snip.../build/CMakeFiles/ocapture.dir//./ocapture_generated_ocapture.cu.o 


make[2]: *** [CMakeFiles/ocapture.dir/build.make:510: CMakeFiles/ocapture.dir/ocapture_generated_ocapture.cu.o] Error 1 
make[1]: *** [CMakeFiles/Makefile2:67: CMakeFiles/ocapture.dir/all] Error 2 
make: *** [Makefile:84: all] Error 2 
+2

2011 년부터 C++에 튜플이있었습니다. 그러나 가장 가능성있는 설명은 'std :: ref'를 사용하여 비 lvalue를 스레드 함수에 전달하는 것입니다. 'std :: ref'를 사용하여 평범하고 네이티브 포인터를 매개 변수로 사용하는 새로운 스레드 메소드에 매개 변수를 전달함으로써 정확히 달성 할 것으로 기대되는 것은 무엇입니까? 그리고이 포인터가 보이기 때문에 클래스 멤버 인 것처럼 보입니다. 왜 이것을 명시 적으로 클래스 메소드에 전달해야합니까? –

+0

감사합니다. 나는 코드를 변경했다 : prototype windowRender (void), 그리고 std :: ref()로 멤버 함수를 넘겼다. 새로운 오류에 대한 원본 게시물을 참조하십시오 ... – Raydude

+0

표시된 조각에서 명백하게 잘못된 점은 없으므로 누구나 스스로 컴파일을 시도 할 수 있으므로 [mcve]가 없으면 더 이상 제안 할 수 없습니다. –

답변

1

나는 며칠 정확한 같은 문제를 했어 내가 "스레드"에 결론을 읽을 때 나는 GCC 6.1.0에 실패하는 테스트 프로젝트를 생성 관리 :

업데이트 5.3.0에서 작동합니다.

CUDA에서 컴파일 할 때 이 실패 할 때 주목해야합니다. 즉, 실행 프로그램은 .cu 파일입니다. .cpp 파일로 컴파일하면 컴파일 프로세스에서 -pthread 플래그를 설정하여 문제가 해결됩니다.

현재이 때문에 5.3.0으로 작업 중입니다. 나는 여기에 실패한 코드를 첨부 할 것이다. 만드는 데 사용되는 소프트웨어는 실패 :

CMake 10, 닌자, GCC 6.3.0, CUDA 9.0.176

실행기 :

#include "ClassWithT/Functions.hpp" 
#include <stdlib.h> 
#include <iostream> 

int main() 
{ 

    int* m = (int*)malloc(2 * sizeof(int)); 
    float* n = (float*)malloc(2 * sizeof(float)); 
    m[0] = 5; 
    m[1] = 6; 
    n[0] = 2.5f; 
    n[1] = 5.6f; 
    Functions<int>* f = new Functions<int>(m, 2, 0); 
    std::cout << f->ManagingFutures() << std::endl; 

    Functions<float>* g = new Functions<float>(n, 2, 0); 
    std::cout << g->ManagingFutures() << std::endl; 

    return 0; 
} 

Functions.ipp을 :

#pragma once 
#include "Functions.hpp" 

template<class T> 
Functions<T>::Functions(T* list, int numValues, bool type) 
{ 
    valuesList = list; 
    numberOfValuesInList = numValues; 
    typeOfOperation = type; 
} 

template<class T> 
T Functions<T>::DoSomeStuff() 
{ 

    T intAmount; 
    if (typeOfOperation == 0) 
    { 
     intAmount = valuesList[0] + valuesList[1]; 
    } 
    else 
    { 
     intAmount = valuesList[0] - valuesList[1]; 
    } 
    return intAmount; 
} 

template<class T> 
T Functions<T>::ManagingFutures() 
{ 
    std::future<T> testThread; 
    testThread = std::async(std::launch::async, &Functions::DoSomeStuff, this); 
    return testThread.get(); 
} 

Functions.hpp :

#pragma once 

#ifndef FUNCTIONS_HPP 
#define FUNCTIONS_HPP 
#include <future> 
template<class T> 
class Functions 
{ 
public: 

    Functions(T* intList, int numIntegers, bool type); 
    T DoSomeStuff(); 
    T ManagingFutures(); 
private: 

    T* valuesList; 
    int numberOfValuesInList; 
    bool typeOfOperation; 

}; 

#include "Functions.ipp" 

#endif 

나는 그것이 아직 실패한 이유를 모르겠다. Nvidia 나 GCC에 버그를 일으킬 수 있습니까?

재현하여 문제를 일으키고, 자유롭게 의견을 말하고, 도와 드리겠습니다.

안녕하세요.

+0

이 메시지를 보았습니다. 엔비디아와 함께 사건을여 셨나요? 이 코드를 보내면 디버깅 할 것입니다. 나는 여전히 gcc 6.4와 cuda 9.0에서이 문제를 겪고있다. gcc 5.4가 정상적으로 작동합니다. 당신의 코드로 nvidia를 사용하여 케이스를 열어 두겠다. 우선, 나는 cuda 9.1을 먼저 시험해보고 버그 보고서를 제출한다. – Raydude

+0

안녕하세요. 예, Nvidia에 버그 케이스를 열었습니다. 만약 당신이 9.1을 가지고 계시다면, 그 정보로 버그 케이스를 업데이트하기 위해서 나를 계속 게시 해주십시오. 나는 그들이 정기적으로 버그 신고를 확인했지만 아직 소식이 없다는 것을 알고 있습니다. – Dread

+0

최대한 빨리 9.1 ebuild에서 작업하겠습니다. 이번 주말에 산만 해졌다. – Raydude