From 281284fa5d7ccd32c7d2e6106313648da5a96548 Mon Sep 17 00:00:00 2001 From: Jesper Stemann Andersen Date: Mon, 27 Mar 2017 18:38:04 +0200 Subject: [PATCH] Fixed building and warnings on Arduino (16 bit platform). (#4197) Building on Arduino fixed by conditional includes of cstdint and utility. In the Standard C++ for Arduino (port of uClibc++): * cstdint is not present. * utility is named utility.h. Replaced size_t with uoffset_t for Verifier::max_tables_, max_depth_, depth_, and num_tables_ to ensure 32-bit values are used (and not 16-bit) - gave rise to a warning. --- include/flatbuffers/flatbuffers.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h index 048167c55..7b79891c4 100644 --- a/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/flatbuffers.h @@ -19,12 +19,18 @@ #include +#ifndef ARDUINO #include +#endif #include #include #include #include +#ifndef ARDUINO #include +#else +#include +#endif #include #include #include @@ -1388,8 +1394,8 @@ inline bool BufferHasIdentifier(const void *buf, const char *identifier) { // Helper class to verify the integrity of a FlatBuffer class Verifier FLATBUFFERS_FINAL_CLASS { public: - Verifier(const uint8_t *buf, size_t buf_len, size_t _max_depth = 64, - size_t _max_tables = 1000000) + Verifier(const uint8_t *buf, size_t buf_len, uoffset_t _max_depth = 64, + uoffset_t _max_tables = 1000000) : buf_(buf), end_(buf + buf_len), depth_(0), max_depth_(_max_depth), num_tables_(0), max_tables_(_max_tables) #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE @@ -1551,10 +1557,10 @@ class Verifier FLATBUFFERS_FINAL_CLASS { private: const uint8_t *buf_; const uint8_t *end_; - size_t depth_; - size_t max_depth_; - size_t num_tables_; - size_t max_tables_; + uoffset_t depth_; + uoffset_t max_depth_; + uoffset_t num_tables_; + uoffset_t max_tables_; #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE mutable const uint8_t *upper_bound_; #endif