Commit 3effe184 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Remove duplicated template functions on Windows

Because wchar_t is the same as char16 on Windows, and by extension
std::wstring is the same as string16, instantiating templates using both
of these types leads to duplicate instantiations. This error is only
reported when building with -fno-delayed-template-parsing, but it is
always dodgy/wrong.

Microsoft is working towards supporting correct template parsing which
means that we can also (because they are fixing their headers).

The (simplified) error messages were:
error: duplicate explicit instantiation of 'PrepareForUTF8Output<wchar_t>'
ignored as a Microsoft extension
error: duplicate explicit instantiation of 'PrepareForUTF16Or32Output<>
ignored as a Microsoft extension

Bug: 825352
Change-Id: I5360b14f48277d56c3800238cc77077f13ef9acf
Reviewed-on: https://chromium-review.googlesource.com/981083
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546034}
parent 496814ca
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "base/strings/utf_string_conversion_utils.h" #include "base/strings/utf_string_conversion_utils.h"
#include "base/third_party/icu/icu_utf.h" #include "base/third_party/icu/icu_utf.h"
#include "build/build_config.h"
namespace base { namespace base {
...@@ -121,7 +122,10 @@ void PrepareForUTF8Output(const CHAR* src, ...@@ -121,7 +122,10 @@ void PrepareForUTF8Output(const CHAR* src,
} }
// Instantiate versions we know callers will need. // Instantiate versions we know callers will need.
#if !defined(OS_WIN)
// wchar_t and char16 are the same thing on Windows.
template void PrepareForUTF8Output(const wchar_t*, size_t, std::string*); template void PrepareForUTF8Output(const wchar_t*, size_t, std::string*);
#endif
template void PrepareForUTF8Output(const char16*, size_t, std::string*); template void PrepareForUTF8Output(const char16*, size_t, std::string*);
template<typename STRING> template<typename STRING>
...@@ -142,7 +146,10 @@ void PrepareForUTF16Or32Output(const char* src, ...@@ -142,7 +146,10 @@ void PrepareForUTF16Or32Output(const char* src,
} }
// Instantiate versions we know callers will need. // Instantiate versions we know callers will need.
#if !defined(OS_WIN)
// std::wstring and string16 are the same thing on Windows.
template void PrepareForUTF16Or32Output(const char*, size_t, std::wstring*); template void PrepareForUTF16Or32Output(const char*, size_t, std::wstring*);
#endif
template void PrepareForUTF16Or32Output(const char*, size_t, string16*); template void PrepareForUTF16Or32Output(const char*, size_t, string16*);
} // namespace base } // namespace base
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