[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gpsd-dev] [PATCH 5/8] NITEMS definition cleanup.
From: |
Rob Norris |
Subject: |
[gpsd-dev] [PATCH 5/8] NITEMS definition cleanup. |
Date: |
Tue, 19 Apr 2016 21:01:42 +0100 |
Remove NITEMS from jsongen.py.in
Add protection around the definitions and add a version in libgps.h for use in
libgps
TESTED:
'scons build-all check' passes
---
gpsd.h-tail | 2 ++
jsongen.py | 2 --
libgps.h | 4 ++++
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/gpsd.h-tail b/gpsd.h-tail
index 7c52740..85990f0 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -945,7 +945,9 @@ PRINTF_FUNC(3, 4) void gpsd_log(const struct gpsd_errout_t
*, const int, const c
*/
#define EMIX(x, y) (((x) > (y)) ? (x) : (y))
+#ifndef NITEMS
#define NITEMS(x) ((int) (sizeof(x) / sizeof(x[0]) +
COMPILE_CHECK_IS_ARRAY(x)))
+#endif
/* Ugh - required for build on Solaris */
#ifndef NAN
diff --git a/jsongen.py b/jsongen.py
index db1f27f..72b1237 100755
--- a/jsongen.py
+++ b/jsongen.py
@@ -1029,8 +1029,6 @@ if __name__ == '__main__':
print("""/*
* This is code generated by jsongen.py. Do not hand-hack it!
*/
- #define NITEMS(x) (int)(sizeof(x)/sizeof(x[0]))
-
/*@ -fullinitblock */
""")
diff --git a/libgps.h b/libgps.h
index 70d4b7d..f2c4791 100644
--- a/libgps.h
+++ b/libgps.h
@@ -41,6 +41,10 @@ extern int gps_dbus_mainloop(struct gps_data_t *, int,
extern int json_ais_read(const char *, char *, size_t, struct ais_t *,
const char **);
+#ifndef NITEMS
+#define NITEMS(x) ((int) (sizeof(x) / sizeof(x[0]) +
COMPILE_CHECK_IS_ARRAY(x)))
+#endif
+
/* debugging apparatus for the client library */
#ifdef CLIENTDEBUG_ENABLE
#define LIBGPS_DEBUG
--
2.8.0.rc3
- [gpsd-dev] [PATCH 5/8] NITEMS definition cleanup.,
Rob Norris <=