diff --git a/capn.h b/capn.h index cf9cedb..acb42ad 100644 --- a/capn.h +++ b/capn.h @@ -16,6 +16,8 @@ extern "C" { #define CAPN_INLINE static #endif +#define CAPN_VERSION 1 + /* struct capn is a common structure shared between segments in the same * session/context so that far pointers between segments will be created. * diff --git a/compiler/c++.capnp.h b/compiler/c++.capnp.h index dfb34ac..babead7 100644 --- a/compiler/c++.capnp.h +++ b/compiler/c++.capnp.h @@ -3,6 +3,11 @@ /* AUTO GENERATED - DO NOT EDIT */ #include +#if CAPN_VERSION != 1 +#error "version mismatch between capn.h and generated code" +#endif + + #ifdef __cplusplus extern "C" { #endif diff --git a/compiler/capnpc-c.c b/compiler/capnpc-c.c index 61404bf..1868ac0 100644 --- a/compiler/capnpc-c.c +++ b/compiler/capnpc-c.c @@ -1152,7 +1152,10 @@ int main() { str_addf(&HDR, "#ifndef CAPN_%X%X\n", (uint32_t) (file_node->n.id >> 32), (uint32_t) file_node->n.id); str_addf(&HDR, "#define CAPN_%X%X\n", (uint32_t) (file_node->n.id >> 32), (uint32_t) file_node->n.id); str_addf(&HDR, "/* AUTO GENERATED - DO NOT EDIT */\n"); - str_addf(&HDR, "#include \n"); + str_addf(&HDR, "#include \n\n"); + str_addf(&HDR, "#if CAPN_VERSION != 1\n"); + str_addf(&HDR, "#error \"version mismatch between capn.h and generated code\"\n"); + str_addf(&HDR, "#endif\n\n"); capn_resolve(&file_req.imports.p); diff --git a/compiler/schema.capnp.h b/compiler/schema.capnp.h index e3c47a3..6443f90 100644 --- a/compiler/schema.capnp.h +++ b/compiler/schema.capnp.h @@ -2,6 +2,11 @@ #define CAPN_A93FC509624C72D9 /* AUTO GENERATED - DO NOT EDIT */ #include + +#if CAPN_VERSION != 1 +#error "version mismatch between capn.h and generated code" +#endif + #include "c++.capnp.h" #ifdef __cplusplus diff --git a/compiler/test.capnp.h b/compiler/test.capnp.h index f5165a2..98ea44e 100644 --- a/compiler/test.capnp.h +++ b/compiler/test.capnp.h @@ -2,6 +2,11 @@ #define CAPN_D508EEBDC2DC42B8 /* AUTO GENERATED - DO NOT EDIT */ #include + +#if CAPN_VERSION != 1 +#error "version mismatch between capn.h and generated code" +#endif + #include "c++.capnp.h" #ifdef __cplusplus