Fix STATIC_ASSERT macro when using multiple .proto files.
[apps/low-level-can-service.git] / pb.h
diff --git a/pb.h b/pb.h
index 72b4196..22b10d8 100644 (file)
--- a/pb.h
+++ b/pb.h
@@ -6,6 +6,8 @@
  * see pb_encode.h or pb_decode.h
  */
 
+#define NANOPB_VERSION nanopb-0.1.8-dev
+
 #include <stdint.h>
 #include <stddef.h>
 #include <stdbool.h>
@@ -24,7 +26,9 @@
 
 /* Compile-time assertion, used for checking compatible compilation options. */
 #ifndef STATIC_ASSERT
-#define STATIC_ASSERT(COND,MSG) typedef char static_assertion_##MSG[(COND)?1:-1];
+#define STATIC_ASSERT(COND,MSG) typedef char STATIC_ASSERT_MSG(MSG, __LINE__, __COUNTER__)[(COND)?1:-1];
+#define STATIC_ASSERT_MSG(MSG, LINE, COUNTER) STATIC_ASSERT_MSG_(MSG, LINE, COUNTER)
+#define STATIC_ASSERT_MSG_(MSG, LINE, COUNTER) static_assertion_##MSG##LINE##COUNTER
 #endif
 
 /* Number of required fields to keep track of