[Libreoffice-commits] core.git: extensions/source include/comphelper

Tor Lillqvist tml at collabora.com
Wed May 30 11:47:32 UTC 2018


 extensions/source/ole/unoobjw.cxx         |    3 +++
 include/comphelper/windowsdebugoutput.hxx |    5 +++++
 2 files changed, 8 insertions(+)

New commits:
commit 3cce079c9307315f18b6f49f1de58f52e956e0d6
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed May 30 13:59:53 2018 +0300

    Handle <codecvt> deprecation issue with VS2017
    
    As VS2017 so eloquently puts it, "Warning STL4017:
    std::wbuffer_convert, std::wstring_convert, and the <codecvt> header
    (containing std::codecvt_mode, std::codecvt_utf8, std::codecvt_utf16,
    and std::codecvt_utf8_utf16) are deprecated in C++17. (The
    std::codecvt class template is NOT deprecated.) The C++ Standard
    doesn't provide equivalent non-deprecated fu tml_ nctionality;
    consider using MultiByteToWideChar() and WideCharToMultiByte() from
    <Windows.h> instead. You can define
    _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING or
    _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have
    received this warning."
    
    So VS2017 actually recommends using platform-specific API instead of
    standard C++ API that is or will be deprecated but has no standard
    replacement. Insane.
    
    Note that it is not enough to define that
    _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING just right where you
    are including <codecvt> because "for all of the warning suppression
    macros, you must define them before any C++ Standard Library header
    has been included (both <vector> etc. and <cstdlib> etc.)" as
    mentioned on
    https://blogs.msdn.microsoft.com/vcblog/2017/12/08/c17-feature-removals-and-deprecations/
    
    So define it in the single file that includes windowsdebugoutput.hxx
    for now.
    
    Change-Id: Iecd9702502ce3b33013d6799c618d6b98d803c3e

diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx
index 1e2525791ee9..9cbbbbd9139f 100644
--- a/extensions/source/ole/unoobjw.cxx
+++ b/extensions/source/ole/unoobjw.cxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+// See https://blogs.msdn.microsoft.com/vcblog/2017/12/08/c17-feature-removals-and-deprecations/
+#define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING 1
+
 #include "ole2uno.hxx"
 
 #include <stdio.h>
diff --git a/include/comphelper/windowsdebugoutput.hxx b/include/comphelper/windowsdebugoutput.hxx
index fddf3593eacf..a09ccd389af2 100644
--- a/include/comphelper/windowsdebugoutput.hxx
+++ b/include/comphelper/windowsdebugoutput.hxx
@@ -15,6 +15,11 @@
 #ifndef INCLUDED_COMPHELPER_WINDOWSDEBUGOUTPUT_HXX
 #define INCLUDED_COMPHELPER_WINDOWSDEBUGOUTPUT_HXX
 
+// If you get a warning about <codecvt> being deprecated from VS2017, you need to add a "#define
+// _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING 1" to your source file before any #include
+// statements. It would not be enough to have that here. See
+// https://blogs.msdn.microsoft.com/vcblog/2017/12/08/c17-feature-removals-and-deprecations/
+
 #include <codecvt>
 #include <iomanip>
 #include <ostream>


More information about the Libreoffice-commits mailing list