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
path: root/docs
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2022-03-28 17:00:36 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2022-03-28 17:03:53 +0300
commitdb9ac6ba21e30d886bad85c3b9db7619301bdea6 (patch)
treeceb54ff93e1f06b9e00b2af1d2451a9534ed5c29 /docs
parent529d26bb3a6e669e7f812de9f4a999e16e2dfbe5 (diff)
Use C11 static assert mechanism by default (#761, #766)
Hopefully this works better by default and is less confusing when it doesn't. Added notes to migration document on how to restore previous behavior.
Diffstat (limited to 'docs')
-rw-r--r--docs/migration.md19
-rw-r--r--docs/reference.md2
2 files changed, 21 insertions, 0 deletions
diff --git a/docs/migration.md b/docs/migration.md
index 52711b5..f781276 100644
--- a/docs/migration.md
+++ b/docs/migration.md
@@ -31,6 +31,25 @@ as `:`.
**Error indications:** "`protoc: Unknown flag: --nanopb_opt`"
+### `pb.h` uses C11 `_Static_assert` keyword by default
+
+**Rationale:** The nanopb generated headers use static assertions to catch
+errors at compile time. There are several mechanisms to implement this.
+The most widely supported is C11 `_Static_assert` keyword.
+Previously the code used negative size array definition trick, which is
+supported already in C99 but does not work with every compiler and can
+produce confusing error messages.
+
+**Changes:** Now `_Static_assert` is used by default. If preferred, the
+old default behavior can be restored by defining `PB_C99_STATIC_ASSERT`
+in `pb.h` or on compiler command line.
+
+**Required actions:** If the keyword is not recognized, set the compiler to
+C11 standard mode if available. If it is not available, define either `PB_C99_STATIC_ASSERT`
+or `PB_NO_STATIC_ASSERT`.
+
+**Error indications:** "`Undefined identifier _Static_assert`
+
Nanopb-0.4.4 (2020-11-25)
-------------------------
diff --git a/docs/reference.md b/docs/reference.md
index e378881..2d591ae 100644
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -20,6 +20,8 @@ includes nanopb headers.
* `PB_ENCODE_ARRAYS_UNPACKED`: Encode scalar arrays in the unpacked format, which takes up more space. Only to be used when the decoder on the receiving side cannot process packed arrays, such as [protobuf.js versions before 2020](https://github.com/protocolbuffers/protobuf/issues/1701).
* `PB_CONVERT_DOUBLE_FLOAT`: Convert doubles to floats for platforms that do not support 64-bit `double` datatype. Mainly `AVR` processors.
* `PB_VALIDATE_UTF8`: Check whether incoming strings are valid UTF-8 sequences. Adds a small performance and code size penalty.
+* `PB_C99_STATIC_ASSERT`: Use C99 style negative array trick for static assertions. For compilers that do not support C11 standard.
+* `PB_NO_STATIC_ASSERT`: Disable static assertions at compile time. Only for compilers with limited support of C standards.
The `PB_MAX_REQUIRED_FIELDS` and `PB_FIELD_32BIT` settings allow
raising some datatype limits to suit larger messages. Their need is