opensourcerouting / c-capnproto

C library/compiler for the Cap'n Proto serialization/RPC protocol
MIT License
118 stars 40 forks source link

generated files include c.capnp.h but this header is not installed #22

Open cquartier opened 7 years ago

cquartier commented 7 years ago

I see this included even in the file tests/addressbook.capnp.h

https://github.com/opensourcerouting/c-capnproto/blob/master/tests/addressbook.capnp.h#L10

#include "c.capnp.h"

This header file is not installed by make install

Why is this file included in the resulting schema header? If it is necessary shouldn't c.capnp.h be installed along with other headers?

detly commented 4 years ago

I encountered this problem too. It appears to be necessary if you use

using C = import "/capnp/c.capnp";
$C.fieldgetset;

I don't have a workaround but I'm looking into it.

detly commented 3 years ago

I "solved" this by adding an annotation that allows you to omit the include directive from generated files. For example, c.capnp has ID 0xc0183dd65ffef0f3. So in your schema file, you'd put:

using C = import "/capnp/c.capnp";

$C.donotinclude(0xc0183dd65ffef0f3);

The C files generated from this schema will not have #include "c.capnp.h" in them.

You can see this in my annotations branch.