Kaydet (Commit) 3cce079c authored tarafından Tor Lillqvist's avatar Tor Lillqvist

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
üst d7f69b1c
......@@ -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>
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment