diff --git a/applications/test/DLList/Test-DLList.C b/applications/test/DLList/Test-DLList.C
index d970c61d6b6339d891da0fd462c613b49f206f24..75e9e54b37e178e9a2ec143d27d719c9ce535af2 100644
--- a/applications/test/DLList/Test-DLList.C
+++ b/applications/test/DLList/Test-DLList.C
@@ -41,8 +41,8 @@ using namespace Foam;
 template<class T>
 void printAddress(const UList<T>& list)
 {
-    Info<< "list addr: " << long(&list)
-        << " data addr: " << long(list.cdata()) << nl;
+    Info<< "list addr: " << uintptr_t(&list)
+        << " data addr: " << uintptr_t(list.cdata()) << nl;
 }
 
 
diff --git a/applications/test/DynamicList/Test-DynamicList.C b/applications/test/DynamicList/Test-DynamicList.C
index 1d7a7a7ac2a6f0c9b2f9f7e8e3c703aa6d602f6f..83087e4b2530de3653850ac9f2ffce244196c222 100644
--- a/applications/test/DynamicList/Test-DynamicList.C
+++ b/applications/test/DynamicList/Test-DynamicList.C
@@ -50,7 +50,7 @@ void printInfo
         Info<< " size=\"" << lst.size() << "\"";
         if (lst.cdata())
         {
-            Info<< " ptr=\"" << long(lst.cdata()) << "\"";
+            Info<< " ptr=\"" << uintptr_t(lst.cdata()) << "\"";
         }
         else
         {
@@ -76,7 +76,7 @@ void printInfo
             << "\" capacity=\"" << lst.capacity() << "\"";
         if (lst.cdata())
         {
-            Info<< " ptr=\"" << long(lst.cdata()) << "\"";
+            Info<< " ptr=\"" << uintptr_t(lst.cdata()) << "\"";
         }
         else
         {
diff --git a/applications/test/FixedList/Test-FixedList.C b/applications/test/FixedList/Test-FixedList.C
index c753c5506a9f7a7caf59bba434ab7d0e16f94aa9..be7bff686cdc76d8cc2998c353c6fa1e72707b4f 100644
--- a/applications/test/FixedList/Test-FixedList.C
+++ b/applications/test/FixedList/Test-FixedList.C
@@ -50,7 +50,7 @@ Ostream& printInfo(const FixedList<List<T>, N>& list)
     Info<< list << " addresses:";
     for (unsigned i = 0; i < N; ++i)
     {
-        Info<< " " << long(list[i].cdata());
+        Info<< " " << uintptr_t(list[i].cdata());
     }
     Info<< nl;
     return Info;
@@ -210,21 +210,24 @@ int main(int argc, char *argv[])
             << "list2: " << list2 << nl;
 
         // Addresses don't change with swap
-        Info<< "mem: " << long(list1.data()) << " " << long(list2.data()) << nl;
+        Info<< "mem: "
+            << uintptr_t(list1.data()) << " " << uintptr_t(list2.data()) << nl;
 
         list1.swap(list2);
         Info<< "The swap() method" << nl;
         Info<< "list1: " << list1 << nl
             << "list2: " << list2 << nl;
 
-        Info<< "mem: " << long(list1.data()) << " " << long(list2.data()) << nl;
+        Info<< "mem: "
+            << uintptr_t(list1.data()) << " " << uintptr_t(list2.data()) << nl;
 
         Swap(list1, list2);
         Info<< "The Swap() function" << nl;
         Info<< "list1: " << list1 << nl
             << "list2: " << list2 << nl;
 
-        Info<< "mem: " << long(list1.data()) << " " << long(list2.data()) << nl;
+        Info<< "mem: "
+            << uintptr_t(list1.data()) << " " << uintptr_t(list2.data()) << nl;
 
         Info<< "====" << nl;
 
diff --git a/applications/test/HashPtrTable/Test-HashPtrTable.C b/applications/test/HashPtrTable/Test-HashPtrTable.C
index 4d9700db66e3f9b1754ea87564151080495a015a..da6ca717e85a7ce5afeb80c02f1463964b5a5c9a 100644
--- a/applications/test/HashPtrTable/Test-HashPtrTable.C
+++ b/applications/test/HashPtrTable/Test-HashPtrTable.C
@@ -45,7 +45,7 @@ void printTable(const HashPtrTable<T>& table)
         Info<< iter.key() << " = ";
         if (ptr)
         {
-            Info<< *ptr << " (" << long(ptr) << ")";
+            Info<< *ptr << " (" << uintptr_t(ptr) << ")";
         }
         else
         {
diff --git a/applications/test/HashTable2/Test-HashTable2.C b/applications/test/HashTable2/Test-HashTable2.C
index a4a838735eda10aaf711b4e57ed7386c7ee13124..8e343a71d3451fef8e9ebc4a15c2402cf317584f 100644
--- a/applications/test/HashTable2/Test-HashTable2.C
+++ b/applications/test/HashTable2/Test-HashTable2.C
@@ -172,7 +172,7 @@ int main(int argc, char *argv[])
             if (iter.good())
             {
                 Info<< "have " << k << nl
-                    << "    addr: " << long(*iter) << nl
+                    << "    addr: " << uintptr_t(*iter) << nl
                     << "    info: " << (*iter)->info() << nl
                     << "    info: " << iter->info() << nl
                     << "    incr: " << iter->increment() << nl
@@ -214,7 +214,7 @@ int main(int argc, char *argv[])
             if (iter1.good())
             {
                 Info<< "have " << k << nl
-                    << "    addr: " << long(*iter1) << nl
+                    << "    addr: " << uintptr_t(*iter1) << nl
                     << "    info: " << (*iter1)->info() << nl
                     << "    info: " << iter1->info() << nl
                     << "    incr: " << iter1->increment() << nl
@@ -225,7 +225,7 @@ int main(int argc, char *argv[])
             if (iter2.good())
             {
                 Info<< "have " << k << nl
-                    << "    addr: " << long(*iter2) << nl
+                    << "    addr: " << uintptr_t(*iter2) << nl
                     << "    info: " << (*iter2)->info() << nl
                     << "    info: " << iter2->info() << nl
                     // Good: does not compile
@@ -237,7 +237,7 @@ int main(int argc, char *argv[])
             if (iter3.good())
             {
                 Info<< "have " << k << nl
-                    << "    addr: " << long(*iter3) << nl
+                    << "    addr: " << uintptr_t(*iter3) << nl
                     << "    info: " << (*iter3)->info() << nl
                     << "    info: " << iter3->info() << nl
                     // Good: does not compile
diff --git a/applications/test/IOobjectList/Test-IOobjectList.C b/applications/test/IOobjectList/Test-IOobjectList.C
index 92f58b3246e70d1574a06d62f076023b9dbcea1a..92871430b24cc2fe2904c00712460bd734d06838 100644
--- a/applications/test/IOobjectList/Test-IOobjectList.C
+++ b/applications/test/IOobjectList/Test-IOobjectList.C
@@ -69,7 +69,7 @@ void reportDetail(const IOobjectList& objects)
         }
 
         Info<< key << " (" << io->headerClassName()
-            << ") = addr " << long(io) << nl;
+            << ") = addr " << uintptr_t(io) << nl;
 
         if (count != 1)
         {
diff --git a/applications/test/IjkField/Test-IjkField.C b/applications/test/IjkField/Test-IjkField.C
index 8ce4216069da3f662850ac922bd528cd51fc22f8..8abb6a8568ddadb57fc99c65c170ec5d287d1b9e 100644
--- a/applications/test/IjkField/Test-IjkField.C
+++ b/applications/test/IjkField/Test-IjkField.C
@@ -36,7 +36,7 @@ template<class T>
 Ostream& print(const IjkField<T>& fld)
 {
     Info<< static_cast<const Field<T>&>(fld).size()
-        << " addr:" << long(fld.cdata()) << ' ' << fld.sizes() << ' '
+        << " addr:" << uintptr_t(fld.cdata()) << ' ' << fld.sizes() << ' '
         << flatOutput(fld);
 
     return Info;
@@ -149,15 +149,15 @@ int main(int argc, char *argv[])
 
 
     Info<< nl
-        << "Before transfer: addr:" << long(field1.data())
+        << "Before transfer: addr:" << uintptr_t(field1.data())
         << " size:" << field1.size() << nl;
 
     Field<scalar> sfield1(std::move(field1));
     field1.clear();
 
     Info<< "After transfer to regular field" << nl
-        << "    source:" << long(field1.data()) << nl
-        << "    target:" << long(sfield1.data()) << nl
+        << "    source:" << uintptr_t(field1.data()) << nl
+        << "    target:" << uintptr_t(sfield1.data()) << nl
         << "Values"
         << "    source:";
     print(field1) << nl;
diff --git a/applications/test/List3/Test-List3.C b/applications/test/List3/Test-List3.C
index 95423354bb90decad3d0652edcb1d9e1c3f66894..79dd0f18fe72160f42d054b9ee5d38f9cce65dd8 100644
--- a/applications/test/List3/Test-List3.C
+++ b/applications/test/List3/Test-List3.C
@@ -47,15 +47,15 @@ using namespace Foam;
 template<class T>
 void printAddress(const UList<T>& list)
 {
-    Info<< "list addr: " << long(&list)
-        << " data addr: " << long(list.cdata()) << nl;
+    Info<< "list addr: " << uintptr_t(&list)
+        << " data addr: " << uintptr_t(list.cdata()) << nl;
 }
 
 
 template<class T>
 void printAddress(const SLList<T>& list)
 {
-    Info<< "list addr: " << long(&list)
+    Info<< "list addr: " << uintptr_t(&list)
         << " data addr: ???" << nl;
 }
 
diff --git a/applications/test/PtrList/Test-PtrList.C b/applications/test/PtrList/Test-PtrList.C
index 2d7edcf82806d65eb5761e13eafb7a7705938cf0..e3ad64a58a7ad6d7976e31f177b31d1b5ed2290a 100644
--- a/applications/test/PtrList/Test-PtrList.C
+++ b/applications/test/PtrList/Test-PtrList.C
@@ -107,7 +107,7 @@ Ostream& printAddr
 
     for (label i=0; i < len; ++i)
     {
-        os << "addr=" << long(list(i)) << nl;
+        os << "addr=" << uintptr_t(list(i)) << nl;
     }
 
     // End delimiter
@@ -193,7 +193,7 @@ Ostream& print
         {
             const T* ptr = list(i);
 
-            os << "unused " << long(ptr) << nl;
+            os << "unused " << uintptr_t(ptr) << nl;
         }
     }
 
diff --git a/applications/test/PtrMap/Test-PtrMap.C b/applications/test/PtrMap/Test-PtrMap.C
index 6e575d7ff6e115a9dc0129dee9fbff06d60fb885..958bb0d3d45bc086da6abc3d351663f77d5c2e5e 100644
--- a/applications/test/PtrMap/Test-PtrMap.C
+++ b/applications/test/PtrMap/Test-PtrMap.C
@@ -42,7 +42,7 @@ void printTable(const PtrMap<T>& table)
         Info<< iter.key() << " = ";
         if (ptr)
         {
-            Info<< *ptr << " (" << long(ptr) << ")";
+            Info<< *ptr << " (" << uintptr_t(ptr) << ")";
         }
         else
         {
diff --git a/applications/test/SLList/Test-SLList.C b/applications/test/SLList/Test-SLList.C
index a990f3147d131ec79d6f1c45b858f9ff1123a237..e9569307ba5250483dcb9e78a545ad2e7cc66538 100644
--- a/applications/test/SLList/Test-SLList.C
+++ b/applications/test/SLList/Test-SLList.C
@@ -41,8 +41,8 @@ using namespace Foam;
 template<class T>
 void printAddress(const UList<T>& list)
 {
-    Info<< "list addr: " << long(&list)
-        << " data addr: " << long(list.cdata()) << nl;
+    Info<< "list addr: " << uintptr_t(&list)
+        << " data addr: " << uintptr_t(list.cdata()) << nl;
 }
 
 
diff --git a/applications/test/Tuple2/Test-Tuple2.C b/applications/test/Tuple2/Test-Tuple2.C
index fc407e57dffda8caee91d272358897d4439dd2cc..63564a404ddaf0a25972baaeed50049bc550ee94 100644
--- a/applications/test/Tuple2/Test-Tuple2.C
+++ b/applications/test/Tuple2/Test-Tuple2.C
@@ -75,8 +75,8 @@ void printTuple2(const Tuple2<word, word>& t)
 {
     Info<< "tuple: " << t << nl;
 
-    Info<< "first  @: " << long(t.first().data()) << nl;
-    Info<< "second @: " << long(t.second().data()) << nl;
+    Info<< "first  @: " << uintptr_t(t.first().data()) << nl;
+    Info<< "second @: " << uintptr_t(t.second().data()) << nl;
 }
 
 
@@ -85,8 +85,8 @@ void printTuple2(const Pair<word>& t)
 {
     Info<< "tuple: " << t << nl;
 
-    Info<< "first  @: " << long(t.first().data()) << nl;
-    Info<< "second @: " << long(t.second().data()) << nl;
+    Info<< "first  @: " << uintptr_t(t.first().data()) << nl;
+    Info<< "second @: " << uintptr_t(t.second().data()) << nl;
 }
 
 
@@ -191,30 +191,30 @@ int main()
         word word1("hello");
         word word2("word");
 
-        Info<< "create with " << word1 << " @ " << long(word1.data())
-            << " " << word2 << " @ " << long(word2.data()) << nl;
+        Info<< "create with " << word1 << " @ " << uintptr_t(word1.data())
+            << " " << word2 << " @ " << uintptr_t(word2.data()) << nl;
 
         Tuple2<word, word> tup(std::move(word2), std::move(word1));
 
         printTuple2(tup);
 
-        Info<< "input is now " << word1 << " @ " << long(word1.data())
-            << " " << word2 << " @ " << long(word2.data()) << nl;
+        Info<< "input is now " << word1 << " @ " << uintptr_t(word1.data())
+            << " " << word2 << " @ " << uintptr_t(word2.data()) << nl;
     }
 
     {
         word word1("hello");
         word word2("word");
 
-        Info<< "create with " << word1 << " @ " << long(word1.data())
-            << " " << word2 << " @ " << long(word2.data()) << nl;
+        Info<< "create with " << word1 << " @ " << uintptr_t(word1.data())
+            << " " << word2 << " @ " << uintptr_t(word2.data()) << nl;
 
         Pair<word> tup(std::move(word2), std::move(word1));
 
         printTuple2(tup);
 
-        Info<< "input is now " << word1 << " @ " << long(word1.data())
-            << " " << word2 << " @ " << long(word2.data()) << nl;
+        Info<< "input is now " << word1 << " @ " << uintptr_t(word1.data())
+            << " " << word2 << " @ " << uintptr_t(word2.data()) << nl;
     }
 
     Info<< "\nEnd\n" << endl;
diff --git a/applications/test/UList/Test-UList.C b/applications/test/UList/Test-UList.C
index 9f928b05dd598054616a78bac1861f5c6e81928b..364eca07cbf55318b0a2da7ddf4dae4d0250974d 100644
--- a/applications/test/UList/Test-UList.C
+++ b/applications/test/UList/Test-UList.C
@@ -46,7 +46,7 @@ using namespace Foam;
 template<class ListType>
 void print(const ListType& list)
 {
-    Info << flatOutput(list) << " data addr: " << long(list.cdata()) << nl;
+    Info << flatOutput(list) << " data addr: " << uintptr_t(list.cdata()) << nl;
 }
 
 
diff --git a/applications/test/autoPtr/Test-autoPtr.C b/applications/test/autoPtr/Test-autoPtr.C
index a7783b3a316aa0f4aa383fe8326a10fdab244b51..05508d8d075bc08e003823230f2e35561713f07f 100644
--- a/applications/test/autoPtr/Test-autoPtr.C
+++ b/applications/test/autoPtr/Test-autoPtr.C
@@ -90,16 +90,17 @@ int main(int argc, char *argv[])
     {
         auto source = identity(8);
         Info<<"move construct from "
-            << flatOutput(source) << " @ " << long(source.cdata())
+            << flatOutput(source) << " @ " << uintptr_t(source.cdata())
             << nl << nl;
 
         auto list = autoPtr<labelList>::New(std::move(source));
 
-        Info<<"created: " << flatOutput(*list) << " @ " << long(list->cdata())
+        Info<<"created: "
+            << flatOutput(*list) << " @ " << uintptr_t(list->cdata())
             << nl << nl;
 
         Info<<"orig: "
-            << flatOutput(source) << " @ " << long(source.cdata())
+            << flatOutput(source) << " @ " << uintptr_t(source.cdata())
             << nl << nl;
     }
 
@@ -136,7 +137,7 @@ int main(int argc, char *argv[])
 
         auto list = autoPtr<labelList>::New(identity(8));
         Info<<"forward to function from "
-            << flatOutput(*list) << " @ " << long(list->cdata())
+            << flatOutput(*list) << " @ " << uintptr_t(list->cdata())
             << nl << nl;
 
         testTransfer2(std::move(list));
@@ -146,7 +147,7 @@ int main(int argc, char *argv[])
         if (list)
         {
             Info<< nl
-                << flatOutput(*list) << " @ " << long(list->cdata())
+                << flatOutput(*list) << " @ " << uintptr_t(list->cdata())
                 << nl;
         }
         else
@@ -184,7 +185,7 @@ int main(int argc, char *argv[])
 
         auto list = autoPtr<labelList>::New(identity(8));
         Info<<"forward to function from "
-            << flatOutput(*list) << " @ " << long(list->cdata())
+            << flatOutput(*list) << " @ " << uintptr_t(list->cdata())
             << nl << nl;
 
         testTransfer2(std::move(list));
@@ -194,7 +195,7 @@ int main(int argc, char *argv[])
         if (list.valid())
         {
             Info<< nl
-                << flatOutput(*list) << " @ " << long(list->cdata())
+                << flatOutput(*list) << " @ " << uintptr_t(list->cdata())
                 << nl;
         }
         else
diff --git a/applications/test/fileName/Test-fileName.C b/applications/test/fileName/Test-fileName.C
index caff0c88bba7710fcd66b85c4c4201f810aa8da2..3a663bec9f05c93daff4219d003a8e1ac385fc47 100644
--- a/applications/test/fileName/Test-fileName.C
+++ b/applications/test/fileName/Test-fileName.C
@@ -621,7 +621,7 @@ int main(int argc, char *argv[])
             os << "file=<" << file << ">" << nl;
         }
 
-        const int oldPosix = POSIX::debug;
+        const int oldDebug = POSIX::debug;
         POSIX::debug = 1;
 
 
@@ -687,7 +687,7 @@ int main(int argc, char *argv[])
             Foam::rmDir(lnB);
         }
 
-        POSIX::debug = oldPosix;
+        POSIX::debug = oldDebug;
 
         // Verify that rmDir works with bad names too
         Foam::rmDir(dirA);
diff --git a/applications/test/foamVersion/Test-foamVersion.C b/applications/test/foamVersion/Test-foamVersion.C
index 3029ac0cf059a4f4b9a2adcba1b47de9d0a64053..7d7f9514a807f13ae93e96210ed05ea1b54d768e 100644
--- a/applications/test/foamVersion/Test-foamVersion.C
+++ b/applications/test/foamVersion/Test-foamVersion.C
@@ -78,8 +78,8 @@ int main()
 
     Info
         << "\nVerify memory addesses are identical:" << nl
-        << "macro     " << long(Foam::FOAMversion) << nl
-        << "namespace " << long(&(foamVersion::version[0])) << nl;
+        << "macro     " << uintptr_t(Foam::FOAMversion) << nl
+        << "namespace " << uintptr_t(&(foamVersion::version[0])) << nl;
 
 
     // Test extraction
diff --git a/applications/test/hashedWordList/Test-hashedWordList.C b/applications/test/hashedWordList/Test-hashedWordList.C
index e7126e6a8edc1ca7e2d853bae82d80843757a130..0734d661ea2ea66378144f01ed7015c0375faf71 100644
--- a/applications/test/hashedWordList/Test-hashedWordList.C
+++ b/applications/test/hashedWordList/Test-hashedWordList.C
@@ -37,7 +37,7 @@ Ostream& printInfo(const hashedWordList& list, bool withAddr=false)
     Info<< flatOutput(list) << nl << list.lookup() << nl;
     if (withAddr)
     {
-        Info<< "addr=" << long(list.cdata()) << nl;
+        Info<< "addr=" << uintptr_t(list.cdata()) << nl;
     }
 
     return Info;
diff --git a/applications/test/nullObject/Test-nullObject.C b/applications/test/nullObject/Test-nullObject.C
index 18f79c306994e54820bfc86d83ae9668055657a8..5f2e65ab9542e32cdd801d1399fbbe6187558b65 100644
--- a/applications/test/nullObject/Test-nullObject.C
+++ b/applications/test/nullObject/Test-nullObject.C
@@ -55,16 +55,14 @@ public:
 template<class T>
 void printInfo(const UList<T>& list)
 {
-    typedef unsigned long ptrval;
-
     std::cout
         << nl
-        << "List : addr: " << ptrval(&list)
+        << "List : addr: " << uintptr_t(&list)
         << " (null: " << isNull(list) << ")" << nl
         << "    size: " << list.size() << " empty: " << list.empty() << nl
-        << "    data: " << ptrval(list.cdata())
-        << " begin=" << ptrval(list.begin())
-        << " end=" << ptrval(list.end()) << nl;
+        << "    data: " << uintptr_t(list.cdata())
+        << " begin=" << uintptr_t(list.begin())
+        << " end=" << uintptr_t(list.end()) << nl;
 
     Info<< list << nl;
 }
@@ -79,10 +77,8 @@ int main()
     SimpleClass* ptrToClass = new SimpleClass;
     SimpleClass& refToClass(*ptrToClass);
 
-    typedef unsigned long ptrval;
-
     std::cout
-        << "nullObject addr=" << ptrval(&(nullObjectPtr)) << nl
+        << "nullObject addr=" << uintptr_t(&(nullObjectPtr)) << nl
         << "  sizeof(nullObject) = " << sizeof(NullObject::nullObject) << nl
         << "  sizeof(void*) = " << sizeof(void*) << nl
         << "  sizeof(labelList) = " << sizeof(labelList) << nl
@@ -90,7 +86,7 @@ int main()
 
     std::cout
         << "nullObject" << nl
-        << "  pointer:" << ptrval(nullObjectPtr->pointer()) << nl
+        << "  pointer:" << uintptr_t(nullObjectPtr->pointer()) << nl
         << "  value:"   << nullObjectPtr->value() << nl << nl;
 
     if (notNull(ptrToClass))
diff --git a/applications/test/tmp/Test-tmp.C b/applications/test/tmp/Test-tmp.C
index ad6b02a6df2f3fe701b9514602ae75780433588b..c37ac68dd41fc7a56f300d2199f76fecf56ecc78 100644
--- a/applications/test/tmp/Test-tmp.C
+++ b/applications/test/tmp/Test-tmp.C
@@ -46,7 +46,7 @@ void printInfo(const tmp<T>& tmpItem)
 {
     Info<< "tmp valid:" << tmpItem.valid()
         << " isTmp:" << tmpItem.isTmp()
-        << " addr: " << long(tmpItem.get());
+        << " addr: " << uintptr_t(tmpItem.get());
 
     if (tmpItem.valid())
     {
diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C
index a7ebc7b2e09daa5545be5782c3394e8509d6e46e..1d5c095dd6b3a0205359be5906149e044942f1b5 100644
--- a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C
+++ b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C
@@ -212,8 +212,8 @@ Foam::PackedList<Width> Foam::reorder
     }
 
     // Verify addresses (for movable refs)
-    // Info<< "reordered in " << long(input.storage().cdata()) << nl
-    //     << "reordered out " << long(output.storage().cdata()) << nl;
+    // Info<< "reordered in " << uintptr_t(input.storage().cdata()) << nl
+    //     << "reordered out " << uintptr_t(output.storage().cdata()) << nl;
 
     return output;
 }
@@ -230,7 +230,7 @@ void Foam::inplaceReorder
     input = reorder(oldToNew, input, prune);
 
     // Verify address (for movable refs)
-    // Info<< "now have " << long(input.storage().cdata()) << nl;
+    // Info<< "now have " << uintptr_t(input.storage().cdata()) << nl;
 }