From e059dcaa58b5859104aae59e5a7ff7c5fa0db4f4 Mon Sep 17 00:00:00 2001 From: Alexey Geraskin Date: Wed, 17 Jul 2019 18:18:13 +0300 Subject: [PATCH] [C++] Workaround for MSVC 2010 for the issue with std::vector and explicitly aligned custom data types Part 2 --- tests/vector3d_pack.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/vector3d_pack.cpp b/tests/vector3d_pack.cpp index 2b35743d1..7ebfd8fcb 100644 --- a/tests/vector3d_pack.cpp +++ b/tests/vector3d_pack.cpp @@ -1,5 +1,15 @@ #include "vector3d_pack.h" +// looks like VS10 does not support std::vector with explicit alignment +// From stackoverflow (https://stackoverflow.com/questions/8456236/how-is-a-vectors-data-aligned): +// +// Visual C++ version 2010 will not work with an std::vector with classes whose alignment are specified. +// The reason is std::vector::resize. +// When compiling, next error appears: +// c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector(870): error C2719: +// '_Val': formal parameter with __declspec(align('8')) won't be aligned [C:\projects\flatbuffers\flattests.vcxproj] +#if !defined(_MSC_VER) || _MSC_VER >= 1700 + #include "native_type_test_generated.h" namespace flatbuffers { @@ -11,3 +21,5 @@ namespace flatbuffers { return Native::Vector3D(obj.x(), obj.y(), obj.z()); } } + +#endif