diff --git a/cpp/src/arrow/ipc/metadata_internal.h b/cpp/src/arrow/ipc/metadata_internal.h index 666c2789e2623..f5ffee3fa759a 100644 --- a/cpp/src/arrow/ipc/metadata_internal.h +++ b/cpp/src/arrow/ipc/metadata_internal.h @@ -96,8 +96,10 @@ struct FileBlock { " in flatbuffer-encoded metadata"); \ } -#define FLATBUFFERS_VECTOR_SIZE(fb_vector) \ - ((fb_vector == NULLPTR) ? 0 : fb_vector->size()) +template +inline uint32_t FlatBuffersVectorSize(const flatbuffers::Vector* vec) { + return (vec == NULLPTR) ? 0 : vec->size(); +} inline std::string StringFromFlatbuffers(const flatbuffers::String* s) { return (s == NULLPTR) ? "" : s->str(); diff --git a/cpp/src/arrow/ipc/reader.cc b/cpp/src/arrow/ipc/reader.cc index ff7fee5950916..f99037a0d3478 100644 --- a/cpp/src/arrow/ipc/reader.cc +++ b/cpp/src/arrow/ipc/reader.cc @@ -657,11 +657,11 @@ class RecordBatchFileReader::RecordBatchFileReaderImpl { } int num_dictionaries() const { - return FLATBUFFERS_VECTOR_SIZE(footer_->dictionaries()); + return static_cast(internal::FlatBuffersVectorSize(footer_->dictionaries())); } int num_record_batches() const { - return FLATBUFFERS_VECTOR_SIZE(footer_->recordBatches()); + return static_cast(internal::FlatBuffersVectorSize(footer_->recordBatches())); } MetadataVersion version() const {