Generated files .h and .c++

27 views
Skip to first unread message

Nogueira

unread,
May 4, 2021, 1:28:43 PM5/4/21
to Cap'n Proto
Hi,

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? 

Thanks!

Kenton Varda

unread,
May 5, 2021, 12:13:09 AM5/5/21
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.

-Kenton

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/d522df33-da2e-4372-bcb6-a3e760b6871fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages