From 52f4f4573e1920e294615c6eb908a2986562e633 Mon Sep 17 00:00:00 2001 From: Stefan Eilemann Date: Sat, 26 Jul 2014 13:12:56 +0200 Subject: [PATCH] Fix OS X build Change-Id: If0465b73843ad1a489fa66318a689801def3f0f0 --- CMakeLists.txt | 12 +++++------- include/flatbuffers/flatbuffers.h | 10 +++++----- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f50c491..be7bddd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,16 +51,14 @@ set(CMAKE_BUILD_TYPE Debug) # source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS}) # source_group(Tests FILES ${FlatBuffers_Tests_SRCS}) -if(CMAKE_COMPILER_IS_GNUCXX) - add_definitions("-std=c++0x") - add_definitions("-Wall") -endif() -if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - add_definitions("-std=c++0x") +if(APPLE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++ -Wall") +elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall") endif() if(FLATBUFFERS_CODE_COVERAGE) - add_definitions("-g -fprofile-arcs -ftest-coverage") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") endif() diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h index 5f943ba..690db2b 100644 --- a/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/flatbuffers.h @@ -299,8 +299,8 @@ class vector_downward { void clear() { cur_ = buf_ + reserved_; } - size_t growth_policy(size_t size) { - return (size / 2) & ~(sizeof(largest_scalar_t) - 1); + size_t growth_policy(size_t bytes) { + return (bytes / 2) & ~(sizeof(largest_scalar_t) - 1); } uint8_t *make_space(size_t len) { @@ -331,9 +331,9 @@ class vector_downward { // push() & fill() are most frequently called with small byte counts (<= 4), // which is why we're using loops rather than calling memcpy/memset. - void push(const uint8_t *bytes, size_t size) { - auto dest = make_space(size); - for (size_t i = 0; i < size; i++) dest[i] = bytes[i]; + void push(const uint8_t *bytes, size_t num) { + auto dest = make_space(num); + for (size_t i = 0; i < num; i++) dest[i] = bytes[i]; } void fill(size_t zero_pad_bytes) { -- 2.7.4