Generated files .h and .c++

Skip to first unread message


May 4, 2021, 1:28:43 PMMay 4
to Cap'n Proto

I have been using capnproto to perform serialization and de-serialization using mmap. Works pretty well and it's fast! 
I noticed I'm able to compile and use code without the generated .c++ file, which seems to have some hardcoded tables in it.
What exactly is the c++ file used for? Am I encountering any problem if I use the header but not the c++ file? 


Kenton Varda

May 5, 2021, 12:13:09 AMMay 5
to Nogueira, Cap'n Proto
The tables are used to support the "schema" and "dynamic" APIs (aka "reflection"). These APIs are useful for a bunch of things, and in particular they are used to implement text stringification of messages (e.g. for debugging) and JSON conversion.

I think some code is also generated in the .c++ file for RPC interfaces.

If you don't get a linker error when you omit the .c++ file, then you must not be using these features. It's fine to omit the file if you don't see any errors from doing so. Note, though, that you might find you suddenly need the .c++ file in the future after some code change, or a future version of Cap'n Proto might start to require it. I'd generally recommend making it part of your build, but configuring your linker to drop unused objects, rather than intentionally omit it.


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
To view this discussion on the web visit
Reply all
Reply to author
0 new messages