From b5e306f7d89e82984a37824a3640bd67a5c45d61 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Wed, 14 Aug 2024 11:01:02 -0400
Subject: Enable /permissive- on MSVC for better standards conformance  (#2251)

* Enable /permissive- on MSVC for better C++ conformance and fix related errors

* Clean up left over warning suppressions from old library or msvc versions
---
 indra/llcommon/llallocator_heap_profile.cpp |  7 -------
 indra/llcommon/llevents.h                   | 10 +---------
 indra/llcommon/llfindlocale.cpp             |  2 +-
 indra/llcommon/llsdjson.cpp                 |  9 ---------
 indra/llcommon/llstacktrace.cpp             |  3 ---
 indra/llcommon/llstring.cpp                 |  5 +++++
 indra/llcommon/llstring.h                   |  5 +++--
 indra/llcommon/lluuid.cpp                   |  1 +
 indra/llcommon/tests/commonmisc_test.cpp    |  6 ------
 9 files changed, 11 insertions(+), 37 deletions(-)

(limited to 'indra/llcommon')

diff --git a/indra/llcommon/llallocator_heap_profile.cpp b/indra/llcommon/llallocator_heap_profile.cpp
index 85e56b4db4..8cc44b6a01 100644
--- a/indra/llcommon/llallocator_heap_profile.cpp
+++ b/indra/llcommon/llallocator_heap_profile.cpp
@@ -28,13 +28,6 @@
 #include "linden_common.h"
 #include "llallocator_heap_profile.h"
 
-#if LL_MSVC
-// disable warning about boost::lexical_cast returning uninitialized data
-// when it fails to parse the string
-#pragma warning (disable:4701)
-#pragma warning (disable:4702)
-#endif
-
 #include <boost/algorithm/string/split.hpp>
 #include <boost/bind.hpp>
 #include <boost/lexical_cast.hpp>
diff --git a/indra/llcommon/llevents.h b/indra/llcommon/llevents.h
index f97fca0a32..4bf1fa07a2 100644
--- a/indra/llcommon/llevents.h
+++ b/indra/llcommon/llevents.h
@@ -38,16 +38,8 @@
 #include <vector>
 #include <deque>
 #include <functional>
-#if LL_WINDOWS
-    #pragma warning (push)
-    #pragma warning (disable : 4263) // boost::signals2::expired_slot::what() has const mismatch
-    #pragma warning (disable : 4264)
-#endif
-#include <boost/signals2.hpp>
-#if LL_WINDOWS
-    #pragma warning (pop)
-#endif
 
+#include <boost/signals2.hpp>
 #include <boost/bind.hpp>
 #include <boost/utility.hpp>        // noncopyable
 #include <boost/optional/optional.hpp>
diff --git a/indra/llcommon/llfindlocale.cpp b/indra/llcommon/llfindlocale.cpp
index ac52f90c9f..b4bcc80ac4 100644
--- a/indra/llcommon/llfindlocale.cpp
+++ b/indra/llcommon/llfindlocale.cpp
@@ -185,7 +185,7 @@ canonise_fl(FL_Locale *l) {
 #define RML(pn,sn) MAKELANGID(LANG_##pn, SUBLANG_##sn)
 struct IDToCode {
   LANGID id;
-  char*  code;
+  const char*  code;
 };
 static const IDToCode both_to_code[] = {
   {ML(ENGLISH,US),           "en_US.ISO_8859-1"},
diff --git a/indra/llcommon/llsdjson.cpp b/indra/llcommon/llsdjson.cpp
index e95d2e6c1c..5d38e55686 100644
--- a/indra/llcommon/llsdjson.cpp
+++ b/indra/llcommon/llsdjson.cpp
@@ -35,16 +35,7 @@
 #include "llerror.h"
 #include "../llmath/llmath.h"
 
-#if LL_WINDOWS
-#pragma warning (push)
-#pragma warning (disable : 4702) // compiler thinks unreachable code
-#endif
 #include <boost/json/src.hpp>
-#if LL_WINDOWS
-#pragma warning (pop)
-#endif
-
-
 
 //=========================================================================
 LLSD LlsdFromJson(const boost::json::value& val)
diff --git a/indra/llcommon/llstacktrace.cpp b/indra/llcommon/llstacktrace.cpp
index bda3579f60..ca8f4299d9 100644
--- a/indra/llcommon/llstacktrace.cpp
+++ b/indra/llcommon/llstacktrace.cpp
@@ -33,10 +33,7 @@
 #include <sstream>
 
 #include "llwin32headerslean.h"
-#pragma warning (push)
-#pragma warning (disable:4091) // a microsoft header has warnings. Very nice.
 #include <dbghelp.h>
-#pragma warning (pop)
 
 typedef USHORT NTAPI RtlCaptureStackBackTrace_Function(
     IN ULONG frames_to_skip,
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index c57f8b1e96..505789f9ea 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -900,6 +900,11 @@ void HeapFree_deleter(void* ptr)
 
 } // anonymous namespace
 
+unsigned long windows_get_last_error()
+{
+    return GetLastError();
+}
+
 template<>
 std::wstring windows_message<std::wstring>(DWORD error)
 {
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index b69a068830..db716b1431 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -46,7 +46,6 @@
 #endif
 
 #include <string.h>
-#include <boost/scoped_ptr.hpp>
 
 const char LL_UNKNOWN_CHAR = '?';
 class LLSD;
@@ -832,8 +831,10 @@ template<>
 LL_COMMON_API std::wstring windows_message<std::wstring>(unsigned long error);
 
 /// Get Windows message string, implicitly calling GetLastError()
+LL_COMMON_API unsigned long windows_get_last_error();
+
 template<typename STRING>
-STRING windows_message() { return windows_message<STRING>(GetLastError()); }
+STRING windows_message() { return windows_message<STRING>(windows_get_last_error()); }
 
 //@}
 
diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp
index 3b37365ec7..7aeabc3c4a 100644
--- a/indra/llcommon/lluuid.cpp
+++ b/indra/llcommon/lluuid.cpp
@@ -31,6 +31,7 @@
 // ugh, this is ugly.  We need to straighten out our linking for this library
 #pragma comment(lib, "IPHLPAPI.lib")
 #include <iphlpapi.h>
+#include <nb30.h>
 #endif
 
 #include "llapp.h"
diff --git a/indra/llcommon/tests/commonmisc_test.cpp b/indra/llcommon/tests/commonmisc_test.cpp
index 0057a1f639..b1a284225e 100644
--- a/indra/llcommon/tests/commonmisc_test.cpp
+++ b/indra/llcommon/tests/commonmisc_test.cpp
@@ -46,12 +46,6 @@
 
 #include "../test/lltut.h"
 
-
-#if LL_WINDOWS
-// disable overflow warnings
-#pragma warning(disable: 4307)
-#endif
-
 namespace tut
 {
     struct sd_data
-- 
cgit v1.2.3