unique_ptr.h error: invalid application of ‘sizeof’ to incomplete type ‘grpc::Server’

1,592 views
Skip to first unread message

alis...@skyiot.co.uk

unread,
Sep 4, 2018, 4:39:27 PM9/4/18
to grpc.io
Hi guys,

I'm currently trying to implement an async server in C++ 14, loosely following the example provided in https://github.com/grpc/grpc/blob/v1.14.1/examples/cpp/helloworld/greeter_async_server.cc

In my class equivalent to ServerImpl in the example, I have the member: 'std::unique_ptr<grpc::Server> server;', just as the ServerImpl has the member 'std::unique_ptr<Server> server_;'

However when I compile I receive the following error, triggered by the presence of the server member variable: 

[build] /usr/include/c++/7/bits/unique_ptr.h: In instantiation of ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = grpc::Server]’:
[build] /usr/include/c++/7/bits/unique_ptr.h:268:17: required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = grpc::Server; _Dp = std::default_delete<grpc::Server>]’
[build] /home/developer/open-iot-server/deployment-management-controller/grpc_server.hpp:50:9: required from here
[build] /usr/include/c++/7/bits/unique_ptr.h:76:22: error: invalid application of ‘sizeof’ to incomplete type ‘grpc::Server’
[build] static_assert(sizeof(_Tp)>0,
[build] ^

I'm relatively new to modern C++ as I've come from an embedded background where C++ 03 is still common-place, so my apologies in advance if this is more a misunderstanding of the correct usage of uniqe_ptr.

Any support/advice would be much appreciated.

Many thanks,
Alistair

Vijay Pai

unread,
Sep 5, 2018, 2:12:13 PM9/5/18
to grpc.io
Do you use the exact same include files? ::grpc::Server shouldn't be incomplete if you are including the header files that we use.

Alistair Lowe

unread,
Sep 5, 2018, 4:43:14 PM9/5/18
to grpc.io
Thank you Vijay,

That's helped resolve the issue, it appears I only had a partial definition included. Looks like I have some familiarisation with GCC error reporting to do!

Many thanks,
Alistair
Reply all
Reply to author
Forward
0 new messages