Commit 281284fa authored by Jesper Stemann Andersen's avatar Jesper Stemann Andersen Committed by Wouter van Oortmerssen

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.
parent 1a27c701
...@@ -19,12 +19,18 @@ ...@@ -19,12 +19,18 @@
#include <assert.h> #include <assert.h>
#ifndef ARDUINO
#include <cstdint> #include <cstdint>
#endif
#include <cstddef> #include <cstddef>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <string> #include <string>
#ifndef ARDUINO
#include <utility> #include <utility>
#else
#include <utility.h>
#endif
#include <type_traits> #include <type_traits>
#include <vector> #include <vector>
#include <set> #include <set>
...@@ -1388,8 +1394,8 @@ inline bool BufferHasIdentifier(const void *buf, const char *identifier) { ...@@ -1388,8 +1394,8 @@ inline bool BufferHasIdentifier(const void *buf, const char *identifier) {
// Helper class to verify the integrity of a FlatBuffer // Helper class to verify the integrity of a FlatBuffer
class Verifier FLATBUFFERS_FINAL_CLASS { class Verifier FLATBUFFERS_FINAL_CLASS {
public: public:
Verifier(const uint8_t *buf, size_t buf_len, size_t _max_depth = 64, Verifier(const uint8_t *buf, size_t buf_len, uoffset_t _max_depth = 64,
size_t _max_tables = 1000000) uoffset_t _max_tables = 1000000)
: buf_(buf), end_(buf + buf_len), depth_(0), max_depth_(_max_depth), : buf_(buf), end_(buf + buf_len), depth_(0), max_depth_(_max_depth),
num_tables_(0), max_tables_(_max_tables) num_tables_(0), max_tables_(_max_tables)
#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
...@@ -1551,10 +1557,10 @@ class Verifier FLATBUFFERS_FINAL_CLASS { ...@@ -1551,10 +1557,10 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
private: private:
const uint8_t *buf_; const uint8_t *buf_;
const uint8_t *end_; const uint8_t *end_;
size_t depth_; uoffset_t depth_;
size_t max_depth_; uoffset_t max_depth_;
size_t num_tables_; uoffset_t num_tables_;
size_t max_tables_; uoffset_t max_tables_;
#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
mutable const uint8_t *upper_bound_; mutable const uint8_t *upper_bound_;
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment