Permalink
Browse files

Enforce NOMINMAX macro everywhere in Mozc.

With recent toolchains such as Visual C++ 2013 and Windows 8.1 SDK, we
are finally able to define NOMINMAX globally and unexceptionally without
breaking dependent libraries.  Now that including Windows.h no longer
defines min/max as a macro, we can remove per-file "#undef min" and
"#undef max" safely.

BUG=
TEST=unittest
REF_BUG=19010851
REF_CL=86940185
  • Loading branch information...
1 parent 4474b76 commit 2cc1a0553421295277e8fc12e2636dcf8ef07f39 @yukawa yukawa committed Nov 9, 2015
View
@@ -686,6 +686,7 @@
'COMPILER_MSVC',
'BUILD_MOZC', # for ime_shared library
'ID_TRACE_LEVEL=1',
+ 'NOMINMAX',
'OS_WIN',
'UNICODE',
'WIN32',
@@ -30,6 +30,8 @@
// skip all unless OS_WIN
#ifdef OS_WIN
+#include <algorithm>
+
#include "ipc/ipc.h"
#include <Windows.h>
@@ -61,7 +63,7 @@ const int kMaxSuccessiveConnectionFailureCount = 5;
size_t GetNumberOfProcessors() {
// thread-safety is not required.
static size_t num = CPUStats().GetNumberOfProcessors();
- return max(num, 1);
+ return max(num, static_cast<size_t>(1));
}
// Least significant bit of OVERLAPPED::hEvent can be used for special
@@ -1,6 +1,6 @@
MAJOR=2
MINOR=17
-BUILD=2221
+BUILD=2222
REVISION=102
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
# downloaded by NaCl Mozc.
@@ -44,14 +44,6 @@
#include "base/stl_util.h"
#include "base/util.h"
-// remove annoying macros
-#ifdef min
-#undef min
-#endif // min
-#ifdef max
-#undef max
-#endif // max
-
namespace mozc {
namespace renderer {
namespace win32 {
@@ -35,8 +35,8 @@
#include <atlapp.h>
#include <atlgdi.h>
#include <atlmisc.h>
-#include <gdiplus.h>
+#include <algorithm>
#include <fstream>
#include <list>
#include <memory>
@@ -52,10 +52,13 @@
DECLARE_string(test_srcdir);
-namespace mozc {
-namespace renderer {
-namespace win32 {
-namespace {
+using ::std::min;
+using ::std::max;
+
+// gdiplus.h must be placed here because it internally depends on
+// global min/max functions.
+// TODO(yukawa): Use WIC (Windows Imaging Component) instead of GDI+.
+#include <gdiplus.h> // NOLINT
using ::mozc::renderer::win32::internal::GaussianBlur;
using ::mozc::renderer::win32::internal::SafeFrameBuffer;
@@ -69,6 +72,11 @@ using ::WTL::CLogFont;
using ::WTL::CPoint;
using ::WTL::CSize;
+namespace mozc {
+namespace renderer {
+namespace win32 {
+namespace {
+
typedef SubdivisionalPixel::SubdivisionalPixelIterator
SubdivisionalPixelIterator;
@@ -36,16 +36,6 @@
#include <atlgdi.h>
#include <atlmisc.h>
-// undef min macro, which conflicts with std::numeric_limits<int>::min().
-#if defined(min)
-#undef min
-#endif // min
-
-// undef max macro, which conflicts with std::numeric_limits<int>::max().
-#if defined(max)
-#undef max
-#endif // max
-
#include <algorithm>
#include <limits>
#include <memory>
@@ -29,8 +29,6 @@
#include "renderer/win32/window_manager.h"
-#undef min
-#undef max
#include <algorithm>
#include <limits>
@@ -35,6 +35,9 @@
#include <atlstr.h> // for CString
#endif // !NO_LOGGING
#include <psapi.h>
+
+#include <algorithm>
+
#include "base/file_util.h"
#include "base/scoped_handle.h"
#include "base/system_util.h"
@@ -39,6 +39,7 @@
#include <atlmisc.h>
#include <strsafe.h>
+#include <algorithm>
#include <memory>
#include "base/const.h"
@@ -349,7 +350,7 @@ class LangBarCallbackImpl : public LangBarCallback {
virtual ULONG AddRef() {
const LONG count = ::InterlockedIncrement(&reference_count_);
- return max(count, 0);
+ return static_cast<ULONG>(max(count, static_cast<LONG>(0)));
}
virtual ULONG Release() {
@@ -47,10 +47,6 @@ using ATL::CComQIPtr;
using ATL::CComVariant;
using std::unique_ptr;
-#ifdef min
-#undef min
-#endif // min
-
// GUID_PROP_INPUTSCOPE
GUID kGuidPropInputscope = {
0x1713dd5a, 0x68e7, 0x4a5b, {0x9a, 0xf6, 0x59, 0x2a, 0x59, 0x5c, 0x77, 0x8d}

0 comments on commit 2cc1a05

Please sign in to comment.