From e658aed6bd631a5b6ded0b3317396f7cc91d8807 Mon Sep 17 00:00:00 2001 From: Jose Luis Blanco-Claraco Date: Fri, 27 Dec 2019 20:42:41 +0100 Subject: [PATCH] MSVC build fixes --- cmake/GtsamBuildTypes.cmake | 5 +++++ gtsam/nonlinear/Values-inl.h | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cmake/GtsamBuildTypes.cmake b/cmake/GtsamBuildTypes.cmake index 06b25ab06..15a02b6e8 100644 --- a/cmake/GtsamBuildTypes.cmake +++ b/cmake/GtsamBuildTypes.cmake @@ -81,6 +81,11 @@ if(MSVC) WINDOWS_LEAN_AND_MEAN NOMINMAX ) + # Avoid literally hundreds to thousands of warnings: + list_append_cache(GTSAM_COMPILE_OPTIONS_PUBLIC + /wd4267 # warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data + ) + endif() # Other (non-preprocessor macros) compiler flags: diff --git a/gtsam/nonlinear/Values-inl.h b/gtsam/nonlinear/Values-inl.h index ff220044a..d0f8a4790 100644 --- a/gtsam/nonlinear/Values-inl.h +++ b/gtsam/nonlinear/Values-inl.h @@ -348,7 +348,9 @@ namespace gtsam { throw ValuesKeyDoesNotExist("at", j); // Check the type and throw exception if incorrect - return internal::handle()(j,item->second); + // h() split in two lines to avoid internal compiler error (MSVC2017) + auto h = internal::handle(); + return h(j,item->second); } /* ************************************************************************* */