feat: Change NANOPB_VERSION macro to string
diff --git a/docs/migration.md b/docs/migration.md
index 5a0a984..78987fc 100644
--- a/docs/migration.md
+++ b/docs/migration.md
@@ -6,6 +6,18 @@
error indications are included, in order to make it easier to find this
document.
+Nanopb-0.4.6 (to come)
+-------------------------
+
+### `NANOPB_VERSION` define is now a string
+
+**Changes:** To ease `NANOPB_VERSION` macro usage, the value is directly a string.
+
+**Required actions:** Most nanopb users probably never used that macro. If so,
+you certainly use the `#` preprocessor to convert it as string. You, now,
+only have to call it directly, like this for exemple:
+`strcpy(myvar, NANOPB_VERSION);`
+
Nanopb-0.4.4 (2020-11-25)
-------------------------
diff --git a/pb.h b/pb.h
index c541799..3bd1908 100644
--- a/pb.h
+++ b/pb.h
@@ -55,7 +55,7 @@
/* Version of the nanopb library. Just in case you want to check it in
* your own program. */
-#define NANOPB_VERSION nanopb-0.4.6-dev
+#define NANOPB_VERSION "nanopb-0.4.6-dev"
/* Include all the system headers needed by nanopb. You will need the
* definitions of the following:
@@ -241,7 +241,7 @@
#define PB_HTYPE_MASK 0x30U
/**** Field allocation types ****/
-
+
#define PB_ATYPE_STATIC 0x00U
#define PB_ATYPE_POINTER 0x80U
#define PB_ATYPE_CALLBACK 0x40U
@@ -368,7 +368,7 @@
bool (*decode)(pb_istream_t *stream, const pb_field_t *field, void **arg);
bool (*encode)(pb_ostream_t *stream, const pb_field_t *field, void * const *arg);
} funcs;
-
+
/* Free arg for use by callback */
void *arg;
};
@@ -401,7 +401,7 @@
*/
bool (*decode)(pb_istream_t *stream, pb_extension_t *extension,
uint32_t tag, pb_wire_type_t wire_type);
-
+
/* Called once after all regular fields have been encoded.
* If you have something to write, do so and return true.
* If you do not have anything to write, just return true.
@@ -409,7 +409,7 @@
* Set to NULL for default handler.
*/
bool (*encode)(pb_ostream_t *stream, const pb_extension_t *extension);
-
+
/* Free field for use by the callback. */
const void *arg;
};
@@ -418,11 +418,11 @@
/* Type describing the extension field. Usually you'll initialize
* this to a pointer to the automatically generated structure. */
const pb_extension_type_t *type;
-
+
/* Destination for the decoded data. This must match the datatype
* of the extension field. */
void *dest;
-
+
/* Pointer to the next extension handler, or NULL.
* If this extension does not match a field, the next handler is
* automatically called. */
@@ -876,4 +876,3 @@
#endif /* __cplusplus */
#endif
-
diff --git a/tools/set_version.sh b/tools/set_version.sh
index 6000619..3dd0c1c 100755
--- a/tools/set_version.sh
+++ b/tools/set_version.sh
@@ -5,7 +5,7 @@
# It sets the version number in pb.h and generator/nanopb_generator.py.
sed -i -e 's/nanopb_version\s*=\s*"[^"]*"/nanopb_version = "'$1'"/' generator/nanopb_generator.py
-sed -i -e 's/#define\s*NANOPB_VERSION\s*.*/#define NANOPB_VERSION '$1'/' pb.h
+sed -i -e 's/#define\s*NANOPB_VERSION\s*.*/#define NANOPB_VERSION "'$1'"/' pb.h
sed -i -e 's/set(\s*nanopb_VERSION_STRING\s*[^)]*)/set(nanopb_VERSION_STRING '$1')/' CMakeLists.txt
VERSION_ONLY=$(echo $1 | sed 's/nanopb-//')