Switch usage of _DEBUG macro to NDEBUG.

http://stackoverflow.com/a/29253284/5237416

BUG=None
R=tommi@webrtc.org
NOPRESUBMIT=true

Review URL: https://codereview.webrtc.org/1429513004

Cr-Commit-Position: refs/heads/master@{#10468}
diff --git a/webrtc/base/diskcache.cc b/webrtc/base/diskcache.cc
index 6bbc53e..7bf1ba2 100644
--- a/webrtc/base/diskcache.cc
+++ b/webrtc/base/diskcache.cc
@@ -23,11 +23,11 @@
 #include "webrtc/base/stringencode.h"
 #include "webrtc/base/stringutils.h"
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
 #define TRANSPARENT_CACHE_NAMES 1
-#else  // !_DEBUG
+#else
 #define TRANSPARENT_CACHE_NAMES 0
-#endif  // !_DEBUG
+#endif
 
 namespace rtc {
 
@@ -211,14 +211,14 @@
 }
 
 bool DiskCache::CheckLimit() {
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   // Temporary check to make sure everything is working correctly.
   size_t cache_size = 0;
   for (EntryMap::iterator it = map_.begin(); it != map_.end(); ++it) {
     cache_size += it->second.size;
   }
   ASSERT(cache_size == total_size_);
-#endif  // _DEBUG
+#endif
 
   // TODO: Replace this with a non-brain-dead algorithm for clearing out the
   // oldest resources... something that isn't O(n^2)
diff --git a/webrtc/base/logging.cc b/webrtc/base/logging.cc
index b02be27..686b9b2 100644
--- a/webrtc/base/logging.cc
+++ b/webrtc/base/logging.cc
@@ -92,13 +92,13 @@
 /////////////////////////////////////////////////////////////////////////////
 
 // By default, release builds don't log, debug builds at info level
-#if _DEBUG
+#if !defined(NDEBUG)
 LoggingSeverity LogMessage::min_sev_ = LS_INFO;
 LoggingSeverity LogMessage::dbg_sev_ = LS_INFO;
-#else  // !_DEBUG
+#else
 LoggingSeverity LogMessage::min_sev_ = LS_NONE;
 LoggingSeverity LogMessage::dbg_sev_ = LS_NONE;
-#endif  // !_DEBUG
+#endif
 bool LogMessage::log_to_stderr_ = true;
 
 namespace {
@@ -340,7 +340,7 @@
                                LoggingSeverity severity,
                                const std::string& tag) {
   bool log_to_stderr = log_to_stderr_;
-#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) && (!defined(_DEBUG) || defined(NDEBUG))
+#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) && defined(NDEBUG)
   // On the Mac, all stderr output goes to the Console log and causes clutter.
   // So in opt builds, don't log to stderr unless the user specifically sets
   // a preference to do so.
diff --git a/webrtc/base/logging.h b/webrtc/base/logging.h
index 1208275..e40ca44 100644
--- a/webrtc/base/logging.h
+++ b/webrtc/base/logging.h
@@ -285,7 +285,7 @@
     rtc::LogMessage(__FILE__, __LINE__, sev).stream()
 
 // The _F version prefixes the message with the current function name.
-#if (defined(__GNUC__) && defined(_DEBUG)) || defined(WANT_PRETTY_LOG_F)
+#if (defined(__GNUC__) && !defined(NDEBUG)) || defined(WANT_PRETTY_LOG_F)
 #define LOG_F(sev) LOG(sev) << __PRETTY_FUNCTION__ << ": "
 #define LOG_T_F(sev) LOG(sev) << this << ": " << __PRETTY_FUNCTION__ << ": "
 #else
diff --git a/webrtc/base/network.cc b/webrtc/base/network.cc
index 879c1e4..32b2a91 100644
--- a/webrtc/base/network.cc
+++ b/webrtc/base/network.cc
@@ -511,14 +511,14 @@
       PIP_ADAPTER_PREFIX prefixlist = adapter_addrs->FirstPrefix;
       std::string name;
       std::string description;
-#ifdef _DEBUG
+#if !defined(NDEBUG)
       name = ToUtf8(adapter_addrs->FriendlyName,
                     wcslen(adapter_addrs->FriendlyName));
 #endif
       description = ToUtf8(adapter_addrs->Description,
                            wcslen(adapter_addrs->Description));
       for (; address; address = address->Next) {
-#ifndef _DEBUG
+#if defined(NDEBUG)
         name = rtc::ToString(count);
 #endif
 
diff --git a/webrtc/base/openssladapter.cc b/webrtc/base/openssladapter.cc
index c906ebb..892b5cc 100644
--- a/webrtc/base/openssladapter.cc
+++ b/webrtc/base/openssladapter.cc
@@ -835,7 +835,7 @@
   return ok;
 }
 
-#if _DEBUG
+#if !defined(NDEBUG)
 
 // We only use this for tracing and so it is only needed in debug mode
 
@@ -864,11 +864,11 @@
   }
 }
 
-#endif  // _DEBUG
+#endif
 
 int
 OpenSSLAdapter::SSLVerifyCallback(int ok, X509_STORE_CTX* store) {
-#if _DEBUG
+#if !defined(NDEBUG)
   if (!ok) {
     char data[256];
     X509* cert = X509_STORE_CTX_get_current_cert(store);
@@ -949,7 +949,7 @@
     return NULL;
   }
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   SSL_CTX_set_info_callback(ctx, SSLInfoCallback);
 #endif
 
diff --git a/webrtc/base/openssladapter.h b/webrtc/base/openssladapter.h
index 3dcb1c5..cdf45e6 100644
--- a/webrtc/base/openssladapter.h
+++ b/webrtc/base/openssladapter.h
@@ -67,9 +67,9 @@
   static bool VerifyServerName(SSL* ssl, const char* host,
                                bool ignore_bad_cert);
   bool SSLPostConnectionCheck(SSL* ssl, const char* host);
-#if _DEBUG
+#if !defined(NDEBUG)
   static void SSLInfoCallback(const SSL* s, int where, int ret);
-#endif  // !_DEBUG
+#endif
   static int SSLVerifyCallback(int ok, X509_STORE_CTX* store);
   static VerificationCallback custom_verify_callback_;
   friend class OpenSSLStreamAdapter;  // for custom_verify_callback_;
diff --git a/webrtc/base/opensslidentity.cc b/webrtc/base/opensslidentity.cc
index feda674..7894b48 100644
--- a/webrtc/base/opensslidentity.cc
+++ b/webrtc/base/opensslidentity.cc
@@ -186,7 +186,7 @@
 #endif
 }
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
 // Print a certificate to the log, for debugging.
 static void PrintCert(X509* x509) {
   BIO* temp_memory_bio = BIO_new(BIO_s_mem());
@@ -215,7 +215,7 @@
     LogSSLErrors("Generating certificate");
     return NULL;
   }
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   PrintCert(x509);
 #endif
   OpenSSLCertificate* ret = new OpenSSLCertificate(x509);
diff --git a/webrtc/base/opensslstreamadapter.cc b/webrtc/base/opensslstreamadapter.cc
index 67ed5db..9c3a09e 100644
--- a/webrtc/base/opensslstreamadapter.cc
+++ b/webrtc/base/opensslstreamadapter.cc
@@ -994,7 +994,7 @@
     return NULL;
   }
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   SSL_CTX_set_info_callback(ctx, OpenSSLAdapter::SSLInfoCallback);
 #endif
 
diff --git a/webrtc/base/physicalsocketserver.cc b/webrtc/base/physicalsocketserver.cc
index 86abcf2..c3abb24 100644
--- a/webrtc/base/physicalsocketserver.cc
+++ b/webrtc/base/physicalsocketserver.cc
@@ -171,12 +171,12 @@
     sockaddr* addr = reinterpret_cast<sockaddr*>(&addr_storage);
     int err = ::bind(s_, addr, static_cast<int>(len));
     UpdateLastError();
-#ifdef _DEBUG
+#if !defined(NDEBUG)
     if (0 == err) {
       dbg_addr_ = "Bound @ ";
       dbg_addr_.append(GetLocalAddress().ToString());
     }
-#endif  // _DEBUG
+#endif
     return err;
   }
 
@@ -361,10 +361,10 @@
     if (err == 0) {
       state_ = CS_CONNECTING;
       enabled_events_ |= DE_ACCEPT;
-#ifdef _DEBUG
+#if !defined(NDEBUG)
       dbg_addr_ = "Listening @ ";
       dbg_addr_.append(GetLocalAddress().ToString());
-#endif  // _DEBUG
+#endif
     }
     return err;
   }
@@ -549,9 +549,9 @@
   ConnState state_;
   AsyncResolver* resolver_;
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   std::string dbg_addr_;
-#endif  // _DEBUG;
+#endif
 };
 
 #if defined(WEBRTC_POSIX)
@@ -1088,10 +1088,10 @@
       if (ff != DE_CONNECT)
         LOG(LS_VERBOSE) << "Signalled with DE_CONNECT: " << ff;
       enabled_events_ &= ~DE_CONNECT;
-#ifdef _DEBUG
+#if !defined(NDEBUG)
       dbg_addr_ = "Connected @ ";
       dbg_addr_.append(GetRemoteAddress().ToString());
-#endif  // _DEBUG
+#endif
       SignalConnectEvent(this);
     }
     if (((ff & DE_ACCEPT) != 0) && (id_ == cache_id)) {
diff --git a/webrtc/base/sigslot.h b/webrtc/base/sigslot.h
index d9b12b0..a5fd5f7 100644
--- a/webrtc/base/sigslot.h
+++ b/webrtc/base/sigslot.h
@@ -532,7 +532,7 @@
 			m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
 		}
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
 			bool connected(has_slots_interface* pclass)
 		{
 			lock_block<mt_policy> lock(this);
@@ -686,7 +686,7 @@
 			m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
 		}
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
 			bool connected(has_slots_interface* pclass)
 		{
 			lock_block<mt_policy> lock(this);
@@ -825,7 +825,7 @@
 			m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
 		}
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
 			bool connected(has_slots_interface* pclass)
 		{
 			lock_block<mt_policy> lock(this);
@@ -963,7 +963,7 @@
 			m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
 		}
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
 			bool connected(has_slots_interface* pclass)
 		{
 			lock_block<mt_policy> lock(this);
@@ -1101,7 +1101,7 @@
 			m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
 		}
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
 			bool connected(has_slots_interface* pclass)
 		{
 			lock_block<mt_policy> lock(this);
@@ -1241,7 +1241,7 @@
 			m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
 		}
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
 			bool connected(has_slots_interface* pclass)
 		{
 			lock_block<mt_policy> lock(this);
@@ -1381,7 +1381,7 @@
 			m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
 		}
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
 			bool connected(has_slots_interface* pclass)
 		{
 			lock_block<mt_policy> lock(this);
@@ -1521,7 +1521,7 @@
 			m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
 		}
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
 			bool connected(has_slots_interface* pclass)
 		{
 			lock_block<mt_policy> lock(this);
@@ -1662,7 +1662,7 @@
 			m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
 		}
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
 			bool connected(has_slots_interface* pclass)
 		{
 			lock_block<mt_policy> lock(this);
diff --git a/webrtc/base/stringutils.cc b/webrtc/base/stringutils.cc
index 868e475..9580253 100644
--- a/webrtc/base/stringutils.cc
+++ b/webrtc/base/stringutils.cc
@@ -77,11 +77,11 @@
   } else if (srclen >= buflen) {
     srclen = buflen - 1;
   }
-#if _DEBUG
+#if !defined(NDEBUG)
   // Double check that characters are not UTF-8
   for (size_t pos = 0; pos < srclen; ++pos)
     RTC_DCHECK_LT(static_cast<unsigned char>(source[pos]), 128);
-#endif  // _DEBUG
+#endif
   std::copy(source, source + srclen, buffer);
   buffer[srclen] = 0;
   return srclen;
diff --git a/webrtc/base/task.cc b/webrtc/base/task.cc
index bdf8f1d..b09ced1 100644
--- a/webrtc/base/task.cc
+++ b/webrtc/base/task.cc
@@ -68,7 +68,7 @@
 
 void Task::Step() {
   if (done_) {
-#ifdef _DEBUG
+#if !defined(NDEBUG)
     // we do not know how !blocked_ happens when done_ - should be impossible.
     // But it causes problems, so in retail build, we force blocked_, and
     // under debug we assert.
@@ -88,7 +88,7 @@
 //   SignalDone();
 
     Stop();
-#ifdef _DEBUG
+#if !defined(NDEBUG)
     // verify that stop removed this from its parent
     ASSERT(!parent()->IsChildTask(this));
 #endif
@@ -125,7 +125,7 @@
 //    SignalDone();
 
     Stop();
-#if _DEBUG
+#if !defined(NDEBUG)
     // verify that stop removed this from its parent
     ASSERT(!parent()->IsChildTask(this));
 #endif
@@ -150,7 +150,7 @@
     // "done_" is set before calling "Stop()" to ensure that this code 
     // doesn't execute more than once (recursively) for the same task.
     Stop();
-#ifdef _DEBUG
+#if !defined(NDEBUG)
     // verify that stop removed this from its parent
     ASSERT(!parent()->IsChildTask(this));
 #endif
diff --git a/webrtc/base/taskparent.cc b/webrtc/base/taskparent.cc
index db6db37..14d236d 100644
--- a/webrtc/base/taskparent.cc
+++ b/webrtc/base/taskparent.cc
@@ -46,7 +46,7 @@
   children_->insert(child);
 }
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
 bool TaskParent::IsChildTask(Task *task) {
   ASSERT(task != NULL);
   return task->parent_ == this && children_->find(task) != children_->end();
@@ -69,7 +69,7 @@
 
 void TaskParent::AbortAllChildren() {
   if (children_->size() > 0) {
-#ifdef _DEBUG
+#if !defined(NDEBUG)
     runner_->IncrementAbortCount();
 #endif
 
@@ -78,7 +78,7 @@
       (*it)->Abort(true);  // Note we do not wake
     }
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
     runner_->DecrementAbortCount();
 #endif
   }
diff --git a/webrtc/base/taskparent.h b/webrtc/base/taskparent.h
index e9342c1..41008fa 100644
--- a/webrtc/base/taskparent.h
+++ b/webrtc/base/taskparent.h
@@ -32,7 +32,7 @@
 
   bool AllChildrenDone();
   bool AnyChildError();
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   bool IsChildTask(Task *task);
 #endif
 
diff --git a/webrtc/base/taskrunner.cc b/webrtc/base/taskrunner.cc
index e7278f1..c50c9f8 100644
--- a/webrtc/base/taskrunner.cc
+++ b/webrtc/base/taskrunner.cc
@@ -23,7 +23,7 @@
   : TaskParent(this),
     next_timeout_task_(NULL),
     tasks_running_(false)
-#ifdef _DEBUG
+#if !defined(NDEBUG)
     , abort_count_(0),
     deleting_task_(NULL)
 #endif
@@ -88,11 +88,11 @@
         need_timeout_recalc = true;
       }
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
       deleting_task_ = task;
 #endif
       delete task;
-#ifdef _DEBUG
+#if !defined(NDEBUG)
       deleting_task_ = NULL;
 #endif
       tasks_[i] = NULL;
diff --git a/webrtc/base/taskrunner.h b/webrtc/base/taskrunner.h
index 9a43aac0..e0cf175 100644
--- a/webrtc/base/taskrunner.h
+++ b/webrtc/base/taskrunner.h
@@ -44,7 +44,7 @@
 
   void UpdateTaskTimeout(Task* task, int64_t previous_task_timeout_time);
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   bool is_ok_to_delete(Task* task) {
     return task == deleting_task_;
   }
@@ -87,7 +87,7 @@
   std::vector<Task *> tasks_;
   Task *next_timeout_task_;
   bool tasks_running_;
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   int abort_count_;
   Task* deleting_task_;
 #endif
diff --git a/webrtc/base/thread.cc b/webrtc/base/thread.cc
index 8ab381f..2a5119b 100644
--- a/webrtc/base/thread.cc
+++ b/webrtc/base/thread.cc
@@ -345,7 +345,7 @@
 
 // static
 void Thread::AssertBlockingIsAllowedOnCurrentThread() {
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   Thread* current = Thread::Current();
   ASSERT(!current || current->blocking_calls_allowed_);
 #endif
diff --git a/webrtc/base/unittest_main.cc b/webrtc/base/unittest_main.cc
index f952b2d..fb74e9e 100644
--- a/webrtc/base/unittest_main.cc
+++ b/webrtc/base/unittest_main.cc
@@ -78,12 +78,12 @@
     _CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestCrtReportHandler);
   }
 
-#ifdef _DEBUG  // Turn on memory leak checking on Windows.
+#if !defined(NDEBUG)  // Turn on memory leak checking on Windows.
   _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF |_CRTDBG_LEAK_CHECK_DF);
   if (FLAG_crt_break_alloc >= 0) {
     _crtBreakAlloc = FLAG_crt_break_alloc;
   }
-#endif  // _DEBUG
+#endif
 #endif  // WEBRTC_WIN
 
   rtc::Filesystem::SetOrganizationName("google");
diff --git a/webrtc/base/win32socketserver.cc b/webrtc/base/win32socketserver.cc
index f466bf1..72ce4eb 100644
--- a/webrtc/base/win32socketserver.cc
+++ b/webrtc/base/win32socketserver.cc
@@ -55,7 +55,7 @@
 static const int ICMP_PING_TIMEOUT_MILLIS = 10000u;
 
 // TODO: Enable for production builds also? Use FormatMessage?
-#ifdef _DEBUG
+#if !defined(NDEBUG)
 LPCSTR WSAErrorToString(int error, LPCSTR *description_result) {
   LPCSTR string = "Unspecified";
   LPCSTR description = "Unspecified description";
@@ -626,7 +626,7 @@
     case FD_CONNECT:
       if (error != ERROR_SUCCESS) {
         ReportWSAError("WSAAsync:connect notify", error, addr_);
-#ifdef _DEBUG
+#if !defined(NDEBUG)
         int32_t duration = TimeSince(connect_time_);
         LOG(LS_INFO) << "WSAAsync:connect error (" << duration
                      << " ms), faking close";
@@ -639,7 +639,7 @@
         // though the connect event never did occur.
         SignalCloseEvent(this, error);
       } else {
-#ifdef _DEBUG
+#if !defined(NDEBUG)
         int32_t duration = TimeSince(connect_time_);
         LOG(LS_INFO) << "WSAAsync:connect (" << duration << " ms)";
 #endif
diff --git a/webrtc/examples/objc/AppRTCDemo/ios/ARDAppDelegate.m b/webrtc/examples/objc/AppRTCDemo/ios/ARDAppDelegate.m
index 0f4165e..9568b94 100644
--- a/webrtc/examples/objc/AppRTCDemo/ios/ARDAppDelegate.m
+++ b/webrtc/examples/objc/AppRTCDemo/ios/ARDAppDelegate.m
@@ -29,7 +29,7 @@
   ARDMainViewController *viewController = [[ARDMainViewController alloc] init];
   _window.rootViewController = viewController;
 
-#ifndef _DEBUG
+#if defined(NDEBUG)
   // In debug builds the default level is LS_INFO and in non-debug builds it is
   // disabled. Continue to log to console in non-debug builds, but only
   // warnings and errors.
diff --git a/webrtc/libjingle/xmpp/xmppclient.cc b/webrtc/libjingle/xmpp/xmppclient.cc
index 7c2a5e6..f7e88c3 100644
--- a/webrtc/libjingle/xmpp/xmppclient.cc
+++ b/webrtc/libjingle/xmpp/xmppclient.cc
@@ -362,7 +362,7 @@
     if (bytes_read == 0)
       return;
 
-//#ifdef _DEBUG
+//#if !defined(NDEBUG)
     client_->SignalLogInput(bytes, static_cast<int>(bytes_read));
 //#endif
 
@@ -386,7 +386,7 @@
 }
 
 void XmppClient::Private::WriteOutput(const char* bytes, size_t len) {
-//#ifdef _DEBUG
+//#if !defined(NDEBUG)
   client_->SignalLogOutput(bytes, static_cast<int>(len));
 //#endif
 
diff --git a/webrtc/libjingle/xmpp/xmpplogintask.cc b/webrtc/libjingle/xmpp/xmpplogintask.cc
index f5745cd..e39713d 100644
--- a/webrtc/libjingle/xmpp/xmpplogintask.cc
+++ b/webrtc/libjingle/xmpp/xmpplogintask.cc
@@ -25,7 +25,7 @@
 
 namespace buzz {
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
 const ConstantLabel XmppLoginTask::LOGINTASK_STATES[] = {
   KLABEL(LOGINSTATE_INIT),
   KLABEL(LOGINSTATE_STREAMSTART_SENT),
@@ -40,7 +40,7 @@
   KLABEL(LOGINSTATE_DONE),
   LASTLABEL
 };
-#endif  // _DEBUG
+#endif
 XmppLoginTask::XmppLoginTask(XmppEngineImpl * pctx) :
   pctx_(pctx),
   authNeeded_(true),
@@ -84,10 +84,10 @@
 
     const XmlElement * element = NULL;
 
-#if _DEBUG
+#if !defined(NDEBUG)
     LOG(LS_VERBOSE) << "XmppLoginTask::Advance - "
       << rtc::ErrorName(state_, LOGINTASK_STATES);
-#endif  // _DEBUG
+#endif
 
     switch (state_) {
 
diff --git a/webrtc/libjingle/xmpp/xmpplogintask.h b/webrtc/libjingle/xmpp/xmpplogintask.h
index 58e0a2f..f69a648 100644
--- a/webrtc/libjingle/xmpp/xmpplogintask.h
+++ b/webrtc/libjingle/xmpp/xmpplogintask.h
@@ -77,9 +77,9 @@
 
   rtc::scoped_ptr<SaslMechanism> sasl_mech_;
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   static const rtc::ConstantLabel LOGINTASK_STATES[];
-#endif  // _DEBUG
+#endif
 };
 
 }
diff --git a/webrtc/libjingle/xmpp/xmpptask.cc b/webrtc/libjingle/xmpp/xmpptask.cc
index 0906705..84f9ba6 100644
--- a/webrtc/libjingle/xmpp/xmpptask.cc
+++ b/webrtc/libjingle/xmpp/xmpptask.cc
@@ -24,7 +24,7 @@
 XmppTask::XmppTask(XmppTaskParentInterface* parent,
                    XmppEngine::HandlerLevel level)
     : XmppTaskBase(parent), stopped_(false) {
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   debug_force_timeout_ = false;
 #endif
 
@@ -70,7 +70,7 @@
 }
 
 void XmppTask::QueueStanza(const XmlElement* stanza) {
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   if (debug_force_timeout_)
     return;
 #endif
diff --git a/webrtc/libjingle/xmpp/xmpptask.h b/webrtc/libjingle/xmpp/xmpptask.h
index 5b97e89..36351b7 100644
--- a/webrtc/libjingle/xmpp/xmpptask.h
+++ b/webrtc/libjingle/xmpp/xmpptask.h
@@ -119,7 +119,7 @@
   std::string task_id() const { return id_; }
   void set_task_id(std::string id) { id_ = id; }
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   void set_debug_force_timeout(const bool f) { debug_force_timeout_ = f; }
 #endif
 
@@ -162,7 +162,7 @@
   rtc::scoped_ptr<XmlElement> next_stanza_;
   std::string id_;
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   bool debug_force_timeout_;
 #endif
 };
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/test/test_iSACfixfloat.c b/webrtc/modules/audio_coding/codecs/isac/fix/test/test_iSACfixfloat.c
index b82af1c..ac0fa35 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/test/test_iSACfixfloat.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/test/test_iSACfixfloat.c
@@ -112,12 +112,12 @@
   char version_number[20];
   int mode = -1, tmp, nbTest = 0; /*,sss;*/
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   FILE* fy;
   double kbps;
   size_t totalbits = 0;
   int totalsmpls = 0;
-#endif /* _DEBUG */
+#endif
 
   /* only one structure used for ISAC encoder */
   ISAC_MainStruct* ISAC_main_inst;
@@ -126,12 +126,12 @@
   BottleNeckModel BN_data;
   f_bn = NULL;
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   fy = fopen("bit_rate.dat", "w");
   fclose(fy);
   fy = fopen("bytes_frames.dat", "w");
   fclose(fy);
-#endif /* _DEBUG */
+#endif
 
   // histfile = fopen("histo.dat", "ab");
   // ratefile = fopen("rates.dat", "ab");
@@ -589,7 +589,7 @@
     fprintf(stderr, "  \rframe = %d", framecnt);
     framecnt++;
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
 
     totalsmpls += declen;
     totalbits += 8 * stream_len;
@@ -598,15 +598,15 @@
     fprintf(fy, "Frame %i = %0.14f\n", framecnt, kbps);
     fclose(fy);
 
-#endif /* _DEBUG */
+#endif
   }
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   printf("\n\ntotal bits               = %" PRIuS " bits", totalbits);
   printf("\nmeasured average bitrate = %0.3f kbits/s",
          (double)totalbits * (FS / 1000) / totalsmpls);
   printf("\n");
-#endif /* _DEBUG */
+#endif
 
   /* Runtime statistics */
   runtime = (double)(clock() / (double)CLOCKS_PER_SEC - starttime);
diff --git a/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc b/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc
index 2e5badd..4cef8f7 100644
--- a/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc
+++ b/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc
@@ -73,10 +73,10 @@
   FILE* plFile;
   int32_t sendBN;
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   FILE* fy;
   double kbps;
-#endif /* _DEBUG */
+#endif
   size_t totalbits = 0;
   int totalsmpls = 0;
 
@@ -103,12 +103,12 @@
 
   BottleNeckModel BN_data;
 
-#ifdef _DEBUG
+#if !defined(NDEBUG)
   fy = fopen("bit_rate.dat", "w");
   fclose(fy);
   fy = fopen("bytes_frames.dat", "w");
   fclose(fy);
-#endif /* _DEBUG */
+#endif
 
   /* Handling wrong input arguments in the command line */
   if ((argc < 3) || (argc > 17)) {
@@ -885,14 +885,14 @@
 
     totalsmpls += declen;
     totalbits += 8 * stream_len;
-#ifdef _DEBUG
+#if !defined(NDEBUG)
     kbps = ((double)sampFreqKHz * 1000.) / ((double)cur_framesmpls) * 8.0 *
            stream_len / 1000.0;  // kbits/s
     fy = fopen("bit_rate.dat", "a");
     fprintf(fy, "Frame %i = %0.14f\n", framecnt, kbps);
     fclose(fy);
 
-#endif /* _DEBUG */
+#endif
   }
   printf("\n");
   printf("total bits               = %" PRIuS " bits\n", totalbits);
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_utility.cc b/webrtc/modules/rtp_rtcp/source/rtp_utility.cc
index bf0b30a..e32fc98 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_utility.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_utility.cc
@@ -23,7 +23,7 @@
 #include <sys/time.h>  // gettimeofday
 #include <time.h>
 #endif
-#if (defined(_DEBUG) && defined(_WIN32) && (_MSC_VER >= 1400))
+#if (!defined(NDEBUG) && defined(_WIN32) && (_MSC_VER >= 1400))
 #include <stdio.h>
 #endif
 
@@ -31,7 +31,7 @@
 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
 #include "webrtc/system_wrappers/include/tick_util.h"
 
-#if (defined(_DEBUG) && defined(_WIN32) && (_MSC_VER >= 1400))
+#if (!defined(NDEBUG) && defined(_WIN32) && (_MSC_VER >= 1400))
 #define DEBUG_PRINT(...)           \
   {                                \
     char msg[256];                 \
@@ -41,7 +41,7 @@
 #else
 // special fix for visual 2003
 #define DEBUG_PRINT(exp)        ((void)0)
-#endif  // defined(_DEBUG) && defined(_WIN32)
+#endif  // !defined(NDEBUG) && defined(_WIN32)
 
 namespace webrtc {
 
diff --git a/webrtc/system_wrappers/include/logging.h b/webrtc/system_wrappers/include/logging.h
index 41c436b..d95c53e 100644
--- a/webrtc/system_wrappers/include/logging.h
+++ b/webrtc/system_wrappers/include/logging.h
@@ -131,7 +131,7 @@
     webrtc::LogMessage(__FILE__, __LINE__, sev).stream()
 
 // The _F version prefixes the message with the current function name.
-#if (defined(__GNUC__) && defined(_DEBUG)) || defined(WANT_PRETTY_LOG_F)
+#if (defined(__GNUC__) && !defined(NDEBUG)) || defined(WANT_PRETTY_LOG_F)
 #define LOG_F(sev) LOG(sev) << __PRETTY_FUNCTION__ << ": "
 #else
 #define LOG_F(sev) LOG(sev) << __FUNCTION__ << ": "
diff --git a/webrtc/voice_engine/voice_engine_defines.h b/webrtc/voice_engine/voice_engine_defines.h
index f78fb2c..f929cd0 100644
--- a/webrtc/voice_engine/voice_engine_defines.h
+++ b/webrtc/voice_engine/voice_engine_defines.h
@@ -135,7 +135,7 @@
   stat.SetLastError(VE_FUNC_NOT_SUPPORTED); \
   return -1;
 
-#if (defined(_DEBUG) && defined(_WIN32) && (_MSC_VER >= 1400))
+#if (!defined(NDEBUG) && defined(_WIN32) && (_MSC_VER >= 1400))
 #include <windows.h>
 #include <stdio.h>
 #define DEBUG_PRINT(...)       \
@@ -147,7 +147,7 @@
 #else
 // special fix for visual 2003
 #define DEBUG_PRINT(exp) ((void)0)
-#endif  // defined(_DEBUG) && defined(_WIN32)
+#endif  // !defined(NDEBUG) && defined(_WIN32)
 
 #define CHECK_CHANNEL(channel)     \
   if (CheckChannel(channel) == -1) \