add version checks

This commit is contained in:
James McKaskill 2013-09-12 23:28:36 -04:00
parent fc63a080a0
commit 7b0bfece26
5 changed files with 21 additions and 1 deletions

2
capn.h
View file

@ -16,6 +16,8 @@ extern "C" {
#define CAPN_INLINE static #define CAPN_INLINE static
#endif #endif
#define CAPN_VERSION 1
/* struct capn is a common structure shared between segments in the same /* struct capn is a common structure shared between segments in the same
* session/context so that far pointers between segments will be created. * session/context so that far pointers between segments will be created.
* *

View file

@ -3,6 +3,11 @@
/* AUTO GENERATED - DO NOT EDIT */ /* AUTO GENERATED - DO NOT EDIT */
#include <capn.h> #include <capn.h>
#if CAPN_VERSION != 1
#error "version mismatch between capn.h and generated code"
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View file

@ -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, "#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, "#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, "/* AUTO GENERATED - DO NOT EDIT */\n");
str_addf(&HDR, "#include <capn.h>\n"); str_addf(&HDR, "#include <capn.h>\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); capn_resolve(&file_req.imports.p);

View file

@ -2,6 +2,11 @@
#define CAPN_A93FC509624C72D9 #define CAPN_A93FC509624C72D9
/* AUTO GENERATED - DO NOT EDIT */ /* AUTO GENERATED - DO NOT EDIT */
#include <capn.h> #include <capn.h>
#if CAPN_VERSION != 1
#error "version mismatch between capn.h and generated code"
#endif
#include "c++.capnp.h" #include "c++.capnp.h"
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -2,6 +2,11 @@
#define CAPN_D508EEBDC2DC42B8 #define CAPN_D508EEBDC2DC42B8
/* AUTO GENERATED - DO NOT EDIT */ /* AUTO GENERATED - DO NOT EDIT */
#include <capn.h> #include <capn.h>
#if CAPN_VERSION != 1
#error "version mismatch between capn.h and generated code"
#endif
#include "c++.capnp.h" #include "c++.capnp.h"
#ifdef __cplusplus #ifdef __cplusplus