From 90cb33b842a17565262bb0646cfb6c3c32e6f292 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Mon, 25 Oct 2010 23:27:28 +0200 Subject: Fix the build with MSVC (really) The previous commit only included the ChangeLog for some reason. 2009-10-26 Armin Burgmeier * MSVC_Net2005/cairomm/cairomm.rc.in: * MSVC_Net2008/cairomm/cairomm.rc.in: Replaced GENERIC_MAJOR_VERSION et al. by CAIROMM_MAJOR_VERSION, so that they are properly replaced during configure. * MSVC_Net2005/examples/image-surface/image-surface.vcproj: * MSVC_Net2005/examples/pdf-surface/pdf-surface.vcproj: * MSVC_Net2005/examples/ps-surface/ps-surface.vcproj: * MSVC_Net2005/examples/svg-surface/svg-surface.vcproj: * MSVC_Net2005/examples/text-rotate/text-rotate.vcproj: * MSVC_Net2005/examples/toy-text/toy-text.vcproj: * MSVC_Net2005/examples/user-font/user-font.vcproj: * MSVC_Net2008/examples/image-surface/image-surface.vcproj: * MSVC_Net2008/examples/pdf-surface/pdf-surface.vcproj: * MSVC_Net2008/examples/ps-surface/ps-surface.vcproj: * MSVC_Net2008/examples/svg-surface/svg-surface.vcproj: * MSVC_Net2008/examples/text-rotate/text-rotate.vcproj: * MSVC_Net2008/examples/toy-text/toy-text.vcproj: * MSVC_Net2008/examples/user-font/user-font.vcproj: Added $(SolutionDir)/cairomm to the include search paths, so that cairommconfig.h is found even if configure did not run. * cairomm/fontface.cc: MSVC does not allow to reinterpret_cast a bool to void*, so use an int instead. * examples/surfaces/image-surface.cc: * examples/surfaces/pdf-surface.cc: * examples/surfaces/ps-surface.cc: * examples/surfaces/svg-surface.cc: * examples/text/text-rotate.cc: Define _USE_MATH_DEFINES before including anything, to make sure we get the defines even if math.h is included indirectly via another header. * cairomm/context.cc: In set_dash(std::valarray), copy the valarray into a vector and then call set_dash(std::vector). The reason is that there is no guarantee that the memory in a std::valarray is contiguous, and also that in MSVC's STL (and also in the C++ standard) std::valarray::operator[](size_t) const returns a T, not a const T&, so &dashes[0] is a compiler error if dashes is a const std::valarray&. --- MSVC_Net2005/cairomm/cairomm.rc.in | 4 ++-- .../examples/image-surface/image-surface.vcproj | 4 ++-- MSVC_Net2005/examples/pdf-surface/pdf-surface.vcproj | 4 ++-- MSVC_Net2005/examples/ps-surface/ps-surface.vcproj | 4 ++-- MSVC_Net2005/examples/svg-surface/svg-surface.vcproj | 4 ++-- MSVC_Net2005/examples/text-rotate/text-rotate.vcproj | 4 ++-- MSVC_Net2005/examples/toy-text/toy-text.vcproj | 4 ++-- MSVC_Net2005/examples/user-font/user-font.vcproj | 4 ++-- MSVC_Net2008/cairomm/cairomm.rc.in | 4 ++-- .../examples/image-surface/image-surface.vcproj | 4 ++-- MSVC_Net2008/examples/pdf-surface/pdf-surface.vcproj | 4 ++-- MSVC_Net2008/examples/ps-surface/ps-surface.vcproj | 4 ++-- MSVC_Net2008/examples/svg-surface/svg-surface.vcproj | 4 ++-- MSVC_Net2008/examples/text-rotate/text-rotate.vcproj | 4 ++-- MSVC_Net2008/examples/toy-text/toy-text.vcproj | 4 ++-- MSVC_Net2008/examples/user-font/user-font.vcproj | 4 ++-- cairomm/context.cc | 19 +++++++++++++++---- examples/surfaces/image-surface.cc | 12 ++++++------ examples/surfaces/pdf-surface.cc | 12 ++++++------ examples/surfaces/ps-surface.cc | 12 ++++++------ examples/surfaces/svg-surface.cc | 12 ++++++------ examples/text/text-rotate.cc | 10 +++++----- 22 files changed, 76 insertions(+), 65 deletions(-) diff --git a/MSVC_Net2005/cairomm/cairomm.rc.in b/MSVC_Net2005/cairomm/cairomm.rc.in index 79c0eee..d968c4d 100644 --- a/MSVC_Net2005/cairomm/cairomm.rc.in +++ b/MSVC_Net2005/cairomm/cairomm.rc.in @@ -33,8 +33,8 @@ END #endif // APSTUDIO_INVOKED VS_VERSION_INFO VERSIONINFO - FILEVERSION @GENERIC_MAJOR_VERSION@,@GENERIC_MINOR_VERSION@,@GENERIC_MICRO_VERSION@,1 - PRODUCTVERSION @GENERIC_MAJOR_VERSION@,@GENERIC_MINOR_VERSION@,@GENERIC_MICRO_VERSION@,1 + FILEVERSION @CAIROMM_MAJOR_VERSION@,@CAIROMM_MINOR_VERSION@,@CAIROMM_MICRO_VERSION@,1 + PRODUCTVERSION @CAIROMM_MAJOR_VERSION@,@CAIROMM_MINOR_VERSION@,@CAIROMM_MICRO_VERSION@,1 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L diff --git a/MSVC_Net2005/examples/image-surface/image-surface.vcproj b/MSVC_Net2005/examples/image-surface/image-surface.vcproj index b265cac..b9e6c29 100644 --- a/MSVC_Net2005/examples/image-surface/image-surface.vcproj +++ b/MSVC_Net2005/examples/image-surface/image-surface.vcproj @@ -44,7 +44,7 @@ #include #include @@ -155,8 +160,11 @@ void Context::set_line_join(LineJoin line_join) void Context::set_dash(std::valarray& dashes, double offset) { - cairo_set_dash(cobj(), &dashes[0], dashes.size(), offset); - check_object_status_and_throw_exception(*this); + std::vector v(dashes.size()); + for(size_t i = 0; i < dashes.size(); ++i) + v[i] = dashes[i]; + + set_dash(v, offset); } void Context::set_dash(std::vector& dashes, double offset) @@ -167,8 +175,11 @@ void Context::set_dash(std::vector& dashes, double offset) void Context::set_dash(const std::valarray& dashes, double offset) { - cairo_set_dash(cobj(), &dashes[0], dashes.size(), offset); - check_object_status_and_throw_exception(*this); + std::vector v(dashes.size()); + for(size_t i = 0; i < dashes.size(); ++i) + v[i] = dashes[i]; + + set_dash(v, offset); } void Context::set_dash(const std::vector& dashes, double offset) diff --git a/examples/surfaces/image-surface.cc b/examples/surfaces/image-surface.cc index 3a349f2..d8ea451 100644 --- a/examples/surfaces/image-surface.cc +++ b/examples/surfaces/image-surface.cc @@ -1,9 +1,3 @@ -#include -#include -#include -#include -#include - /* M_PI is defined in math.h in the case of Microsoft Visual C++, Solaris, * et. al. */ @@ -11,6 +5,12 @@ #define _USE_MATH_DEFINES #endif +#include +#include +#include +#include +#include + #include int main() diff --git a/examples/surfaces/pdf-surface.cc b/examples/surfaces/pdf-surface.cc index a742918..630f196 100644 --- a/examples/surfaces/pdf-surface.cc +++ b/examples/surfaces/pdf-surface.cc @@ -1,9 +1,3 @@ -#include -#include -#include -#include -#include - /* M_PI is defined in math.h in the case of Microsoft Visual C++, Solaris, * et. al. */ @@ -11,6 +5,12 @@ #define _USE_MATH_DEFINES #endif +#include +#include +#include +#include +#include + #include int main() diff --git a/examples/surfaces/ps-surface.cc b/examples/surfaces/ps-surface.cc index 73d630d..4e5bd2a 100644 --- a/examples/surfaces/ps-surface.cc +++ b/examples/surfaces/ps-surface.cc @@ -1,9 +1,3 @@ -#include -#include -#include -#include -#include - /* M_PI is defined in math.h in the case of Microsoft Visual C++, Solaris, * et. al. */ @@ -11,6 +5,12 @@ #define _USE_MATH_DEFINES #endif +#include +#include +#include +#include +#include + #include int main() diff --git a/examples/surfaces/svg-surface.cc b/examples/surfaces/svg-surface.cc index 38f96c9..56e101d 100644 --- a/examples/surfaces/svg-surface.cc +++ b/examples/surfaces/svg-surface.cc @@ -1,9 +1,3 @@ -#include -#include -#include -#include -#include - /* M_PI is defined in math.h in the case of Microsoft Visual C++, Solaris, * et. al. */ @@ -11,6 +5,12 @@ #define _USE_MATH_DEFINES #endif +#include +#include +#include +#include +#include + #include int main() diff --git a/examples/text/text-rotate.cc b/examples/text/text-rotate.cc index 530c2f7..69e02ff 100644 --- a/examples/text/text-rotate.cc +++ b/examples/text/text-rotate.cc @@ -16,11 +16,6 @@ * 02110-1301, USA. */ -#include -#include -#include -#include - /* M_PI is defined in math.h in the case of Microsoft Visual C++, and * Solaris needs math.h for M_PI and floor() */ @@ -28,6 +23,11 @@ #define _USE_MATH_DEFINES #endif +#include +#include +#include +#include + #include // This example is based on the C cairo example of the same name -- cgit v1.2.3