2017-04-12 11 views
0

これは私が取り組んできたゲームボーイエミュレータです、と私は、この時点でこのヘッダーを含める必要があり、なぜ私にはわからない:https://github.com/ryanterry131/JaxBoy/blob/master/src/core/memory/MemoryBus.h#L17C++:私はここにこのヘッダーを含める必要があり、

または他の私これはおそらく、unique_ptrをとは何かを持っている

In file included from src/core/GameBoy.cpp:15: 
In file included from src/core/GameBoy.h:19: 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2535:27: error: 
    invalid application of 'sizeof' to an incomplete type 
    'Memory::MemoryController' 
     static_assert(sizeof(_Tp) > 0, "default_delete can not delet... 
         ^~~~~~~~~~~ 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2736:13: note: 
    in instantiation of member function 
    'std::__1::default_delete<Memory::MemoryController>::operator()' requested 
    here 
     __ptr_.second()(__tmp); 
     ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2704:46: note: 
    in instantiation of member function 
    'std::__1::unique_ptr<Memory::MemoryController, 
    std::__1::default_delete<Memory::MemoryController> >::reset' requested 
    here 
_LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} 
             ^
src/core/memory/MemoryBus.h:31:7: note: in instantiation of member function 
    'std::__1::unique_ptr<Memory::MemoryController, 
    std::__1::default_delete<Memory::MemoryController> >::~unique_ptr' 
    requested here 
class MemoryBus 
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4423:26: note: 
    in instantiation of function template specialization 
    'std::__1::__shared_ptr_emplace<Memory::MemoryBus, 
    std::__1::allocator<Memory::MemoryBus> 
    >::__shared_ptr_emplace<Core::GameBoy *>' requested here 
::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...); 
        ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4787:29: note: 
    in instantiation of function template specialization 
    'std::__1::shared_ptr<Memory::MemoryBus>::make_shared<Core::GameBoy *>' 
    requested here 
return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...); 
         ^
src/core/GameBoy.cpp:36:23: note: in instantiation of function template 
    specialization 'std::__1::make_shared<Memory::MemoryBus, Core::GameBoy *>' 
    requested here 
memory_bus = std::make_shared<Memory::MemoryBus>(this); 
       ^
src/core/memory/MemoryBus.h:29:7: note: forward declaration of 
    'Memory::MemoryController' 
class MemoryController; 

が、私はMemoryBusヘッダにそのヘッダーを含めるように私を必要と何気手掛かりを持っていない:私は理解していない、むしろ大きな誤差を取得します。

ありがとうございました。

+0

'sizeof'カント_full_定義なし' MemoryController'クラスの大きさを測定します。前方宣言はこのためには不十分です。私はどのようにエラーが "不完全な型に 'sizeof'の無効なアプリケーションは"これについてより明確になる可能性がわかりません... –

+0

それは常にunique_ptrを作成するためのケースですか? –

答えて

0

を見てみましょう。

実際には、エラーを回避することができます。unique_ptrCore::GameBoy?)を保持するクラス内のデストラクタを宣言し、そのクラスの.cppファイル内にデストラクタを定義します。

GameBoy.h

class MemoryBus; 

class GameBoy { 
    unique_ptr<MemoryBus> foo; 
public: 
    ~GameBoy(); 
    // ... 
}; 

GameBoy.cpp

GameBoy::~GameBoy() = default; 
関連する問題