From e948caf63779f24f49b7b3e64932368710f1e582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Thu, 22 Apr 2010 14:28:52 +0000 Subject: [PATCH] build with msvc10. Seems there is a bug in their STL code: // std::numpunct has a hardcoded dllimport in definition, but we wanna it with 32 bit // so we can't import it and must define it but then the compiler complains. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34262 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/docstream.cpp | 6 +++ src/support/docstream.h | 10 +++-- src/support/numpunct_lyx_char_type.h | 64 ++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 src/support/numpunct_lyx_char_type.h diff --git a/src/support/docstream.cpp b/src/support/docstream.cpp index 60787a654a..5ae2ff3224 100644 --- a/src/support/docstream.cpp +++ b/src/support/docstream.cpp @@ -23,6 +23,12 @@ using namespace std; using lyx::ucs4_codeset; + +#if defined(_MSC_VER) && (_MSC_VER >= 1600) +std::locale::id numpunct::id; +#endif + + namespace { // We use C IO throughout this file, because the facets might be used with diff --git a/src/support/docstream.h b/src/support/docstream.h index b4a4f80fb1..0a2d42b38b 100644 --- a/src/support/docstream.h +++ b/src/support/docstream.h @@ -14,6 +14,13 @@ #include "support/docstring.h" +#if defined(_MSC_VER) && (_MSC_VER >= 1600) +// Ugly workaround for MSVC10 STL bug: +// std::numpunct has a hardcoded dllimport in definition, but we wanna it with 32 bit +// so we can't import it and must define it but then the compiler complains. +#include "support/numpunct_lyx_char_type.h" +#endif + #include #include @@ -68,9 +75,6 @@ public: }; -#if defined(_MSC_VER) && (_MSC_VER >= 1600) -extern template class std::numpunct; -#endif /// UCS4 input stringstream typedef std::basic_istringstream idocstringstream; diff --git a/src/support/numpunct_lyx_char_type.h b/src/support/numpunct_lyx_char_type.h new file mode 100644 index 0000000000..9dbdeb2c16 --- /dev/null +++ b/src/support/numpunct_lyx_char_type.h @@ -0,0 +1,64 @@ +// -*- C++ -*- +/** + * \file numpunct_lyx_char_type.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Peter Kümmel + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef LYX_NUMPUNCT_LYX_CHAR_TYPE_H +#define LYX_NUMPUNCT_LYX_CHAR_TYPE_H + + +#include + + +namespace std +{ + + template<> + class numpunct : public locale::facet + { + public: + + typedef lyx::char_type char_type; + typedef basic_string string_type; + + + static locale::id id; + + explicit numpunct(size_t __refs = 0) : chared(__refs) + {} + + char_type decimal_point() const + { return chared.decimal_point(); } + + char_type thousands_sep() const + { return chared.thousands_sep(); } + + string grouping() const + { return chared.grouping(); } + + string_type truename() const + { return lyx::from_ascii(chared.truename()); } + + string_type falsename() const + { return lyx::from_ascii(chared.falsename()); } + + + protected: + virtual ~numpunct(); + + + private: + numpunct chared; + + }; + + + +} +#endif