Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nanopb/nanopb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2022-12-22 09:18:05 +0300
committerPetteri Aimonen <jpa@github.mail.kapsi.fi>2022-12-23 09:32:17 +0300
commited530007aa04b31b32fc056e49df4a8fd1080da5 (patch)
tree11c7d2e4b85ea9e3a414cbcd43181480f17b0e61
parent01ca6298754b43b518390e433ee30162a65dd05b (diff)
Use static_assert keyword on MSVC in C89 mode (#843)
-rw-r--r--pb.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/pb.h b/pb.h
index 6a8595a..ef3d83e 100644
--- a/pb.h
+++ b/pb.h
@@ -170,6 +170,9 @@ extern "C" {
# if defined(__ICCARM__)
/* IAR has static_assert keyword but no _Static_assert */
# define PB_STATIC_ASSERT(COND,MSG) static_assert(COND,#MSG);
+# elif defined(_MSC_VER) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112)
+ /* MSVC in C89 mode supports static_assert() keyword anyway */
+# define PB_STATIC_ASSERT(COND,MSG) static_assert(COND,#MSG);
# elif defined(PB_C99_STATIC_ASSERT)
/* Classic negative-size-array static assert mechanism */
# define PB_STATIC_ASSERT(COND,MSG) typedef char PB_STATIC_ASSERT_MSG(MSG, __LINE__, __COUNTER__)[(COND)?1:-1];