Discussion:
[capnproto] Compilation failure with JsonCodec
Krzysztof Sakrejda
2018-03-01 21:50:48 UTC
Permalink
I'm looking for a suggestion about where to look next for fixing this
issue. With these three lines I get a compilation failure:

capnp::JsonCodec json;
capnp::SegmentArrayMessageReader reader(builder.getSegmentsForOutput());
kj::String json_encoded = json.encode(reader);


The failure is on the third line, I'm failing to see if I did something
wrong or if there are caveats to the JSON
encode function that I'm missing. These are schema I can already write out
to a binary stream successfully and
read back so I think those are ok.

Here's the compiler message:

[ 83%] Building CXX object src/capnstan/CMakeFiles/config_writer.dir/
config_writer.cpp.o
In file included from /home/krzysztof/packages/capnStan/downloads/capnproto-
c++/src/capnp/raw-schema.h:29:0,
from /home/krzysztof/packages/capnStan/capnStan/../
downloads/capnproto-c++/src/capnp/generated-header-support.h:31,
from /home/krzysztof/packages/capnStan/capnStan/src/capnp/
stan-config.capnp.h:7,
from /home/krzysztof/packages/capnStan/capnStan/src/
capnstan/config_switch.hpp:34,
from /home/krzysztof/packages/capnStan/capnStan/src/
capnstan/config_writer.cpp:1:
/home/krzysztof/packages/capnStan/downloads/capnproto-c++/src/capnp/common.h
: In substitution of ‘template<class T> using FromAny = typename capnp::
FromAny_<T>::Type [with T = kj::Decay_<capnp::SegmentArrayMessageReader&>::
Type]’:
/home/krzysztof/packages/capnStan/capnStan/../downloads/capnproto-c++/src/
capnp/compat/json.h:215:33: required from ‘kj::String capnp::JsonCodec::
encode(T&&) [with T = capnp::SegmentArrayMessageReader&]’
/home/krzysztof/packages/capnStan/capnStan/src/capnstan/config_writer.cpp:26
:51: required from here
/home/krzysztof/packages/capnStan/downloads/capnproto-c++/src/capnp/common.h
:290:43: error: invalid use of incomplete type ‘struct capnp::FromAny_<capnp
::SegmentArrayMessageReader, void>’
using FromAny = typename FromAny_<T>::Type;
^
/home/krzysztof/packages/capnStan/downloads/capnproto-c++/src/capnp/common.h
:256:8: note: declaration of ‘struct capnp::FromAny_<capnp::
SegmentArrayMessageReader, void>’
struct FromAny_;
^~~~~~~~
--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
'Kenton Varda' via Cap'n Proto
2018-03-01 22:12:33 UTC
Permalink
Hi Krzystof,

The parameter to encode() should be a specific typed Reader, not a
MessageReader. So, something like:

capnp::JsonCodec json;
kj::String json_encoded = json.encode(builder.getRoot<
MyStructType>().asReader());

-Kenton

On Thu, Mar 1, 2018 at 1:50 PM, Krzysztof Sakrejda <
Post by Krzysztof Sakrejda
I'm looking for a suggestion about where to look next for fixing this
capnp::JsonCodec json;
capnp::SegmentArrayMessageReader reader(builder.getSegmentsForOutput
());
kj::String json_encoded = json.encode(reader);
The failure is on the third line, I'm failing to see if I did something
wrong or if there are caveats to the JSON
encode function that I'm missing. These are schema I can already write
out to a binary stream successfully and
read back so I think those are ok.
[ 83%] Building CXX object src/capnstan/CMakeFiles/config_writer.dir/
config_writer.cpp.o
In file included from /home/krzysztof/packages/capnStan/downloads/
capnproto-c++/src/capnp/raw-schema.h:29:0,
from /home/krzysztof/packages/capnStan/capnStan/../
downloads/capnproto-c++/src/capnp/generated-header-support.h:31,
from /home/krzysztof/packages/capnStan/capnStan/src/capnp
/stan-config.capnp.h:7,
from /home/krzysztof/packages/capnStan/capnStan/src/
capnstan/config_switch.hpp:34,
from /home/krzysztof/packages/capnStan/capnStan/src/
/home/krzysztof/packages/capnStan/downloads/capnproto-c++/src/capnp/common
FromAny_<T>::Type [with T = kj::Decay_<capnp::SegmentArrayMessageReader
/home/krzysztof/packages/capnStan/capnStan/../downloads/capnproto-c++/src/
encode(T&&) [with T = capnp::SegmentArrayMessageReader&]’
26:51: required from here
/home/krzysztof/packages/capnStan/downloads/capnproto-c++/src/capnp/common
.h:290:43: error: invalid use of incomplete type ‘struct capnp::FromAny_<
capnp::SegmentArrayMessageReader, void>’
using FromAny = typename FromAny_<T>::Type;
^
/home/krzysztof/packages/capnStan/downloads/capnproto-c++/src/capnp/common
.h:256:8: note: declaration of ‘struct capnp::FromAny_<capnp::Segment
ArrayMessageReader, void>’
struct FromAny_;
^~~~~~~~
--
You received this message because you are subscribed to the Google Groups
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/capnproto.
--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
Krzysztof Sakrejda
2018-03-01 22:21:14 UTC
Permalink
That makes the "incomplete type" message make a lot of sense, thanks! K
Post by 'Kenton Varda' via Cap'n Proto
Hi Krzystof,
The parameter to encode() should be a specific typed Reader, not a
capnp::JsonCodec json;
kj::String json_encoded =
json.encode(builder.getRoot<MyStructType>().asReader());
-Kenton
Post by Krzysztof Sakrejda
I'm looking for a suggestion about where to look next for fixing this
capnp::JsonCodec json;
capnp::SegmentArrayMessageReader reader(builder.getSegmentsForOutput
());
kj::String json_encoded = json.encode(reader);
The failure is on the third line, I'm failing to see if I did something
wrong or if there are caveats to the JSON
encode function that I'm missing. These are schema I can already write
out to a binary stream successfully and
read back so I think those are ok.
[ 83%] Building CXX object src/capnstan/CMakeFiles/config_writer.dir/
config_writer.cpp.o
In file included from /home/krzysztof/packages/capnStan/downloads/
capnproto-c++/src/capnp/raw-schema.h:29:0,
from /home/krzysztof/packages/capnStan/capnStan/../
downloads/capnproto-c++/src/capnp/generated-header-support.h:31,
from /home/krzysztof/packages/capnStan/capnStan/src/
capnp/stan-config.capnp.h:7,
from /home/krzysztof/packages/capnStan/capnStan/src/
capnstan/config_switch.hpp:34,
from /home/krzysztof/packages/capnStan/capnStan/src/
/home/krzysztof/packages/capnStan/downloads/capnproto-c++/src/capnp/
common.h: In substitution of ‘template<class T> using FromAny = typename
/home/krzysztof/packages/capnStan/capnStan/../downloads/capnproto-c++/src
/capnp/compat/json.h:215:33: required from ‘kj::String capnp::JsonCodec
::encode(T&&) [with T = capnp::SegmentArrayMessageReader&]’
/home/krzysztof/packages/capnStan/capnStan/src/capnstan/config_writer.cpp
:26:51: required from here
/home/krzysztof/packages/capnStan/downloads/capnproto-c++/src/capnp/
FromAny_<capnp::SegmentArrayMessageReader, void>’
using FromAny = typename FromAny_<T>::Type;
^
/home/krzysztof/packages/capnStan/downloads/capnproto-c++/src/capnp/
SegmentArrayMessageReader, void>’
struct FromAny_;
^~~~~~~~
--
You received this message because you are subscribed to the Google Groups
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/capnproto.
--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
Loading...