aboutsummaryrefslogtreecommitdiffstats
path: root/pb.h
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@npb.mail.kapsi.fi>2011-07-30 09:59:08 +0000
committerPetteri Aimonen <jpa@npb.mail.kapsi.fi>2011-07-30 09:59:08 +0000
commitf8364310d3ca85d2cf59019bb4bc5e9ff4c52dc3 (patch)
treee5ddbe4c28353630fb4881717058ed5f9cd83db7 /pb.h
parentd7863b7424b1be5da33e9d632365f3e2c0538461 (diff)
unittests (some)
git-svn-id: https://svn.kapsi.fi/jpa/nanopb@949 e3a754e5-d11d-0410-8d38-ebb782a927b9
Diffstat (limited to 'pb.h')
-rw-r--r--pb.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/pb.h b/pb.h
index 370109a1..c075cdec 100644
--- a/pb.h
+++ b/pb.h
@@ -112,8 +112,6 @@ struct _pb_field_t {
const void *ptr;
} pb_packed;
-#define PB_LAST_FIELD {0,0,0,0}
-
/* This structure is used for 'bytes' arrays.
* It has the number of bytes in the beginning, and after that an array. */
#define PB_BYTES_ARRAY(buffersize) \
@@ -152,4 +150,11 @@ struct _pb_callback_t {
void *arg;
};
+/* These macros are used to declare pb_field_t's in the constant array. */
+#define pb_membersize(st, m) (sizeof ((st*)0)->m)
+#define pb_arraysize(st, m) (pb_membersize(st, m) / pb_membersize(st, m[0]))
+#define pb_delta(st, m1, m2) ((int)offsetof(st, m1) - (int)offsetof(st, m2))
+#define PB_LAST_FIELD {0,0,0,0}
+
+
#endif \ No newline at end of file