Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command is incomplete type #13

Closed
DELTA37 opened this issue Oct 16, 2017 · 6 comments
Closed

Command is incomplete type #13

DELTA37 opened this issue Oct 16, 2017 · 6 comments

Comments

@DELTA37
Copy link

DELTA37 commented Oct 16, 2017

In file included from /usr/include/c++/7/memory:80:0,
from /home/delta37/sphere/parallel_programming/afina/include/afina/network/Server.h:4,
from /home/delta37/sphere/parallel_programming/afina/src/network/blocking/ServerImpl.h:8,
from /home/delta37/sphere/parallel_programming/afina/src/network/blocking/ServerImpl.cpp:1:
/usr/include/c++/7/bits/unique_ptr.h: In instantiation of ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = Afina::Execute::Command]’:
/usr/include/c++/7/bits/unique_ptr.h:268:17: required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = Afina::Execute::Command; _Dp = std::default_deleteAfina::Execute::Command]’
/home/delta37/sphere/parallel_programming/afina/src/network/blocking/ServerImpl.cpp:225:40: required from here
/usr/include/c++/7/bits/unique_ptr.h:76:22: error: invalid application of ‘sizeof’ to incomplete type ‘Afina::Execute::Command’
static_assert(sizeof(_Tp)>0,
^
src/network/CMakeFiles/Network.dir/build.make:110: recipe for target 'src/network/CMakeFiles/Network.dir/blocking/ServerImpl.cpp.o' failed
make[2]: *** [src/network/CMakeFiles/Network.dir/blocking/ServerImpl.cpp.o] Error 1
CMakeFiles/Makefile2:742: recipe for target 'src/network/CMakeFiles/Network.dir/all' failed
make[1]: *** [src/network/CMakeFiles/Network.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2

Я хотел воспользоваться классом парсером, подключил в ServerImpl.h Parser.h И создал обьект Parser но при компиляции выскочила такая ошибка

@xphoenix
Copy link
Owner

#include <afina/execute/Command.h> - не?

@DELTA37
Copy link
Author

DELTA37 commented Oct 16, 2017

#14

@DELTA37
Copy link
Author

DELTA37 commented Oct 16, 2017

Проблема в том, что я не мог создать обьект unique_ptrExecute::Command

@DELTA37
Copy link
Author

DELTA37 commented Oct 16, 2017

Прочитал, что если есть виртуальный деструктор, то нужно по идее пользоваться shared_ptr, который гарантирует вызов нужного деструктора

@xphoenix
Copy link
Owner

Ты не запостил саму ошибку, но если она совпадает с заколовком, т.е "Command is incomplete type" то проблема изза того, что компилятор не видит реального класса, т.е Command представлен только как forward declaration из парсера.

Второе, std::unique_ptr<Command> говорит только о том, что указатель, который ты сохранишь должен приводиться к типу Command *, т.е должно быть так std::unique_ptr<Command>(new Execute::Set(....))

@DELTA37
Copy link
Author

DELTA37 commented Oct 16, 2017

Все, спасибо, разобрался, моя ошибка, извиняюсь

@DELTA37 DELTA37 closed this as completed Oct 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants