[sword-devel] [PATCH] Use C++ 11 <cstdint> instead of __{s, u}* typedefs

Adrian Bunk bunk at debian.org
Sat Jun 20 12:56:18 EDT 2020


Names like __u32 do not pollute the POSIX namespace,
but the Linux kernel uses exactly the same names.

On some Linux architectures the kernel definitions are different,
e.g. http://tracker.crosswire.org/browse/API-178

All relevant compilers should now support C++ 11,
but please double-check that this change works on
all non-gcc compilers you support.
---
 CMakeLists.txt                                |   5 +-
 configure.ac                                  |   3 +-
 examples/cmdline/search.cpp                   |   4 +-
 include/rawstr.h                              |   5 +-
 include/rawstr4.h                             |   5 +-
 include/stringmgr.h                           |   9 +-
 include/swkey.h                               |   3 +-
 include/sysdata.h                             |  61 +-
 include/treekeyidx.h                          |  11 +-
 include/utilstr.h                             |   7 +-
 include/xzcomprs.h                            |   3 +-
 m4/ax_cxx_compile_stdcxx.m4                   | 951 ++++++++++++++++++
 src/keys/treekeyidx.cpp                       |  37 +-
 src/keys/versekey.cpp                         |  17 +-
 src/mgr/stringmgr.cpp                         |  25 +-
 src/modules/comments/rawfiles/rawfiles.cpp    |   5 +-
 src/modules/common/entriesblk.cpp             |  21 +-
 src/modules/common/rawstr.cpp                 |  37 +-
 src/modules/common/rawstr4.cpp                |  39 +-
 src/modules/common/rawverse.cpp               |  19 +-
 src/modules/common/rawverse4.cpp              |  21 +-
 src/modules/common/zstr.cpp                   |  73 +-
 src/modules/common/zverse.cpp                 |  49 +-
 src/modules/common/zverse4.cpp                |  51 +-
 src/modules/filters/rtfhtml.cpp               |   5 +-
 src/modules/filters/utf8greekaccents.cpp      |   7 +-
 src/modules/filters/utf8utf16.cpp             |  17 +-
 src/modules/genbook/rawgenbook/rawgenbook.cpp |  11 +-
 src/modules/lexdict/rawld/rawld.cpp           |  10 +-
 src/modules/lexdict/rawld4/rawld4.cpp         |  10 +-
 src/modules/swmodule.cpp                      |   5 +-
 tests/filtertest.cpp                          |   3 +-
 tests/utf8norm.cpp                            |   3 +-
 33 files changed, 1248 insertions(+), 284 deletions(-)
 create mode 100644 m4/ax_cxx_compile_stdcxx.m4

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1aa66701..bbb4d212 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,7 +12,7 @@
 # all posterity and eternity, wherever such transfer is possible.  Where it is
 # not, then this file is released under the GPLv2 by myself.
 PROJECT(libsword CXX C)
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0)
 SET(SWORD_VERSION 1.8.900)
 
 # Make sure it's an out-of-stream build
@@ -155,6 +155,9 @@ ENDIF(BUILDING_SHARED)
 #SET(CMAKE_C_FLAGS                  "${CMAKE_C_FLAGS}"   or "$ENV{CFLAGS}" or "" )
 #SET(CMAKE_CXX_FLAGS                "${CMAKE_CXX_FLAGS}" or "$ENV{CXXFLAGS}" or "" )
 
+SET(CMAKE_CXX_STANDARD 11)
+SET(CMAKE_CXX_STANDARD_REQUIRED ON)
+
 IF(SWORD_ENABLE_WARNINGS STREQUAL "Yes")
 	SET(CMAKE_C_FLAGS "-Werror ${CMAKE_C_FLAGS}")
 	SET(CMAKE_CXX_FLAGS "-Werror ${CMAKE_CXX_FLAGS}")
diff --git a/configure.ac b/configure.ac
index 315bafda..cd587b41 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,6 +37,7 @@ CXXFLAGS=" $CXXFLAGS"
 AC_LANG(C++)
 AC_PROG_CC
 AC_PROG_CXX
+AX_CXX_COMPILE_STDCXX(11)
 AC_PROG_INSTALL
 AC_LIBTOOL_WIN32_DLL
 AC_PROG_LIBTOOL
@@ -302,7 +303,7 @@ else
 fi
 
 if test x$with_cxx11regex = xyes; then
-	AM_CXXFLAGS="$AM_CXXFLAGS -DUSECXX11REGEX -std=c++11"
+	AM_CXXFLAGS="$AM_CXXFLAGS -DUSECXX11REGEX"
 fi
 
 # ---------------------------------------------------------------------
diff --git a/examples/cmdline/search.cpp b/examples/cmdline/search.cpp
index 5fd9e78c..3a54aafb 100644
--- a/examples/cmdline/search.cpp
+++ b/examples/cmdline/search.cpp
@@ -24,6 +24,8 @@
  *
  */
 
+#include <cstdint>
+
 #include <stdio.h>
 #include <rawtext.h>
 #include <swmgr.h>
@@ -134,7 +136,7 @@ int main(int argc, char **argv)
 		SWKey *k = listKey.getElement();
 		std::cout << k->getRangeText();
 //		std::cout << (const char *)listKey;
-		if (k->userData) std::cout << " : " << (__u64)k->userData << "%";
+		if (k->userData) std::cout << " : " << (uint64_t)k->userData << "%";
 		std::cout << std::endl;
 	}
 
diff --git a/include/rawstr.h b/include/rawstr.h
index d25ebc37..cdd05c2c 100644
--- a/include/rawstr.h
+++ b/include/rawstr.h
@@ -26,6 +26,7 @@
 #ifndef RAWSTR_H
 #define RAWSTR_H
 
+#include <cstdint>
 #include <defs.h>
 #include <sysdata.h>
 
@@ -54,8 +55,8 @@ public:
 	virtual ~RawStr();
 	void getIDXBuf(long ioffset, char **buf) const;
 	void getIDXBufDat(long ioffset, char **buf) const;
-	signed char findOffset(const char *key, __u32 *start, __u16 *size, long away = 0, __u32 *idxoff = 0) const;
-	void readText(__u32 start, __u16 *size, char **idxbuf, SWBuf &buf) const;
+	signed char findOffset(const char *key, uint32_t *start, uint16_t *size, long away = 0, uint32_t *idxoff = 0) const;
+	void readText(uint32_t start, uint16_t *size, char **idxbuf, SWBuf &buf) const;
 	static signed char createModule(const char *path);
 };
 
diff --git a/include/rawstr4.h b/include/rawstr4.h
index 0277a25a..36bb0a74 100644
--- a/include/rawstr4.h
+++ b/include/rawstr4.h
@@ -26,6 +26,7 @@
 #ifndef RAWSTR4_H
 #define RAWSTR4_H
 
+#include <cstdint>
 #include <defs.h>
 #include <sysdata.h>
 
@@ -53,8 +54,8 @@ public:
 	virtual ~RawStr4();
 	void getIDXBuf(long ioffset, char **buf) const;
 	void getIDXBufDat(long ioffset, char **buf) const;
-	signed char findOffset(const char *key, __u32 *start, __u32 *size, long away = 0, __u32 *idxoff = 0) const;
-	void readText(__u32 start, __u32 *size, char **idxbuf, SWBuf &buf) const;
+	signed char findOffset(const char *key, uint32_t *start, uint32_t *size, long away = 0, uint32_t *idxoff = 0) const;
+	void readText(uint32_t start, uint32_t *size, char **idxbuf, SWBuf &buf) const;
 	static signed char createModule(const char *path);
 };
 
diff --git a/include/stringmgr.h b/include/stringmgr.h
index 237ba148..8344c42f 100644
--- a/include/stringmgr.h
+++ b/include/stringmgr.h
@@ -25,6 +25,7 @@
 #ifndef STRINGMGR_H
 #define STRINGMGR_H
 
+#include <cstdint>
 #include <defs.h>
 #include <swbuf.h>
 #include <utilstr.h>
@@ -70,10 +71,10 @@ public:
 	*/	
 	virtual char *lowerUTF8(char *text, unsigned int max = 0) const;
 
-	virtual bool isUpper(__u32 character) const;
-	virtual bool isLower(__u32 character) const;
-	virtual bool isDigit(__u32 character) const;
-	virtual bool isAlpha(__u32 character) const;
+	virtual bool isUpper(uint32_t character) const;
+	virtual bool isLower(uint32_t character) const;
+	virtual bool isDigit(uint32_t character) const;
+	virtual bool isAlpha(uint32_t character) const;
    
 	/** Converts the param to an uppercase latin1 string
 	* @param text The text encoded in latin1 which should be turned into an upper case string
diff --git a/include/swkey.h b/include/swkey.h
index 52e94414..4a61f69e 100644
--- a/include/swkey.h
+++ b/include/swkey.h
@@ -27,6 +27,7 @@
 
 #include <swobject.h>
 
+#include <cstdint>
 #include <defs.h>
 #include <sysdata.h>
 #include <utilstr.h>
@@ -114,7 +115,7 @@ protected:
 public:
 
 	// misc storage for whatever
-	__u64 userData;
+	uint64_t userData;
 
 	/** initializes instance of SWKey from a string
 	 * All keys can be reduced to a string representation which should be able
diff --git a/include/sysdata.h b/include/sysdata.h
index f979f29f..ae7fdbd5 100644
--- a/include/sysdata.h
+++ b/include/sysdata.h
@@ -22,64 +22,41 @@
 
 #ifndef SIZEDTYPES_H
 #define SIZEDTYPES_H
-/*
- * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
- * header files exported to user space
- */
+
 #ifdef USE_AUTOTOOLS
 #include "config.h"
 #endif
 
-
-typedef signed char __s8;
-typedef unsigned char __u8;
-
-typedef signed short __s16;
-typedef unsigned short __u16;
-
-typedef signed int __s32;
-typedef unsigned int __u32;
-
-#ifdef OS_ANDROID
-#elif defined(__GNUC__)
-__extension__ typedef __signed__ long long __s64;
-__extension__ typedef unsigned long long __u64;
-#elif defined(__BORLANDC__)
-typedef signed __int64 __s64;
-typedef unsigned __int64 __u64;
-#else
-typedef signed long long __s64;
-typedef unsigned long long __u64;
-#endif
+#include <cstdint>
 
 #undef __swswap16
 #undef __swswap32
 #undef __swswap64
 
 #define __swswap16(x) \
-	((__u16)( \
-		(((__u16)(x) & (__u16)0x00ffU) << 8) | \
-		(((__u16)(x) & (__u16)0xff00U) >> 8) ))
+	((uint16_t)( \
+		(((uint16_t)(x) & (uint16_t)0x00ffU) << 8) | \
+		(((uint16_t)(x) & (uint16_t)0xff00U) >> 8) ))
 
 		
 #define __swswap32(x) \
-	((__u32)( \
-		(((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
-		(((__u32)(x) & (__u32)0x0000ff00UL) <<  8) | \
-		(((__u32)(x) & (__u32)0x00ff0000UL) >>  8) | \
-		(((__u32)(x) & (__u32)0xff000000UL) >> 24) ))
+	((uint32_t)( \
+		(((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
+		(((uint32_t)(x) & (uint32_t)0x0000ff00UL) <<  8) | \
+		(((uint32_t)(x) & (uint32_t)0x00ff0000UL) >>  8) | \
+		(((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24) ))
 
 		
 #define __swswap64(x) \
-	((__u64)( \
-		(__u64)(((__u64)(x) & (__u64)0x00000000000000ffULL) << 56) | \
-		(__u64)(((__u64)(x) & (__u64)0x000000000000ff00ULL) << 40) | \
-		(__u64)(((__u64)(x) & (__u64)0x0000000000ff0000ULL) << 24) | \
-		(__u64)(((__u64)(x) & (__u64)0x00000000ff000000ULL) <<  8) | \
-		   (__u64)(((__u64)(x) & (__u64)0x000000ff00000000ULL) >>  8) | \
-		(__u64)(((__u64)(x) & (__u64)0x0000ff0000000000ULL) >> 24) | \
-		(__u64)(((__u64)(x) & (__u64)0x00ff000000000000ULL) >> 40) | \
-		(__u64)(((__u64)(x) & (__u64)0xff00000000000000ULL) >> 56) ))
+	((uint64_t)( \
+		(uint64_t)(((uint64_t)(x) & (uint64_t)0x00000000000000ffULL) << 56) | \
+		(uint64_t)(((uint64_t)(x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
+		(uint64_t)(((uint64_t)(x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
+		(uint64_t)(((uint64_t)(x) & (uint64_t)0x00000000ff000000ULL) <<  8) | \
+		   (uint64_t)(((uint64_t)(x) & (uint64_t)0x000000ff00000000ULL) >>  8) | \
+		(uint64_t)(((uint64_t)(x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
+		(uint64_t)(((uint64_t)(x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
+		(uint64_t)(((uint64_t)(x) & (uint64_t)0xff00000000000000ULL) >> 56) ))
 		
 
 
diff --git a/include/treekeyidx.h b/include/treekeyidx.h
index 331b7e83..f89ae6e1 100644
--- a/include/treekeyidx.h
+++ b/include/treekeyidx.h
@@ -24,6 +24,7 @@
 #ifndef TREEKEYIDX_H
 #define TREEKEYIDX_H
 
+#include <cstdint>
 #include <treekey.h>
 #include <sysdata.h>
 
@@ -42,12 +43,12 @@ class SWDLLEXPORT TreeKeyIdx : public TreeKey {
 		TreeNode();
 		~TreeNode();
 		void clear();
-		__s32 offset;
-		__s32 parent;
-		__s32 next;
-		__s32 firstChild;
+		int32_t offset;
+		int32_t parent;
+		int32_t next;
+		int32_t firstChild;
 		char *name;
-		__u16 dsize;
+		uint16_t dsize;
 		char *userData;
 	} currentNode;
 
diff --git a/include/utilstr.h b/include/utilstr.h
index 77ca5b16..c573b6aa 100644
--- a/include/utilstr.h
+++ b/include/utilstr.h
@@ -23,6 +23,7 @@
 #ifndef UTILSTR_H
 #define UTILSTR_H
 
+#include <cstdint>
 #include <defs.h>
 #include <sysdata.h>
 #include <swbuf.h>
@@ -85,8 +86,8 @@ extern const unsigned char SW_tolower_array[256];
  * 		unicode codepoint value (0 with buf incremented is invalid UTF8 byte
  */
 
-inline __u32 getUniCharFromUTF8(const unsigned char **buf, bool skipValidation = false) {
-	__u32 ch = 0;
+inline uint32_t getUniCharFromUTF8(const unsigned char **buf, bool skipValidation = false) {
+	uint32_t ch = 0;
 
 	//case: We're at the end
 	if (!(**buf)) {
@@ -162,7 +163,7 @@ inline __u32 getUniCharFromUTF8(const unsigned char **buf, bool skipValidation =
  * 		to work with
  */
 
-inline SWBuf *getUTF8FromUniChar(__u32 uchar, SWBuf *appendTo) {
+inline SWBuf *getUTF8FromUniChar(uint32_t uchar, SWBuf *appendTo) {
 	unsigned long base = appendTo->size();
 
 	// This would be out of Unicode bounds
diff --git a/include/xzcomprs.h b/include/xzcomprs.h
index f3fe42b2..9568c90c 100644
--- a/include/xzcomprs.h
+++ b/include/xzcomprs.h
@@ -26,6 +26,7 @@
 
 #include <swcomprs.h>
 
+#include <cstdint>
 #include <defs.h>
 #include <sysdata.h>
 
@@ -42,7 +43,7 @@ public:
 	virtual void Decode(void);
 	virtual void setLevel(int l);
 private:
-	__u64 memlimit; // memory usage limit during decompression
+	uint64_t memlimit; // memory usage limit during decompression
 };
 
 SWORD_NAMESPACE_END
diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4
new file mode 100644
index 00000000..43087b2e
--- /dev/null
+++ b/m4/ax_cxx_compile_stdcxx.m4
@@ -0,0 +1,951 @@
+# ===========================================================================
+#  https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
+#
+# DESCRIPTION
+#
+#   Check for baseline language coverage in the compiler for the specified
+#   version of the C++ standard.  If necessary, add switches to CXX and
+#   CXXCPP to enable support.  VERSION may be '11' (for the C++11 standard)
+#   or '14' (for the C++14 standard).
+#
+#   The second argument, if specified, indicates whether you insist on an
+#   extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
+#   -std=c++11).  If neither is specified, you get whatever works, with
+#   preference for an extended mode.
+#
+#   The third argument, if specified 'mandatory' or if left unspecified,
+#   indicates that baseline support for the specified C++ standard is
+#   required and that the macro should error out if no mode with that
+#   support is found.  If specified 'optional', then configuration proceeds
+#   regardless, after defining HAVE_CXX${VERSION} if and only if a
+#   supporting mode is found.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Benjamin Kosnik <bkoz at redhat.com>
+#   Copyright (c) 2012 Zack Weinberg <zackw at panix.com>
+#   Copyright (c) 2013 Roy Stogner <roystgnr at ices.utexas.edu>
+#   Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov at google.com>
+#   Copyright (c) 2015 Paul Norman <penorman at mac.com>
+#   Copyright (c) 2015 Moritz Klammler <moritz at klammler.eu>
+#   Copyright (c) 2016, 2018 Krzesimir Nowak <qdlacz at gmail.com>
+#   Copyright (c) 2019 Enji Cooper <yaneurabeya at gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.  This file is offered as-is, without any
+#   warranty.
+
+#serial 11
+
+dnl  This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
+dnl  (serial version number 13).
+
+AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
+  m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
+        [$1], [14], [ax_cxx_compile_alternatives="14 1y"],
+        [$1], [17], [ax_cxx_compile_alternatives="17 1z"],
+        [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
+  m4_if([$2], [], [],
+        [$2], [ext], [],
+        [$2], [noext], [],
+        [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl
+  m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true],
+        [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
+        [$3], [optional], [ax_cxx_compile_cxx$1_required=false],
+        [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
+  AC_LANG_PUSH([C++])dnl
+  ac_success=no
+
+  m4_if([$2], [noext], [], [dnl
+  if test x$ac_success = xno; then
+    for alternative in ${ax_cxx_compile_alternatives}; do
+      switch="-std=gnu++${alternative}"
+      cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
+      AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
+                     $cachevar,
+        [ac_save_CXX="$CXX"
+         CXX="$CXX $switch"
+         AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
+          [eval $cachevar=yes],
+          [eval $cachevar=no])
+         CXX="$ac_save_CXX"])
+      if eval test x\$$cachevar = xyes; then
+        CXX="$CXX $switch"
+        if test -n "$CXXCPP" ; then
+          CXXCPP="$CXXCPP $switch"
+        fi
+        ac_success=yes
+        break
+      fi
+    done
+  fi])
+
+  m4_if([$2], [ext], [], [dnl
+  if test x$ac_success = xno; then
+    dnl HP's aCC needs +std=c++11 according to:
+    dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
+    dnl Cray's crayCC needs "-h std=c++11"
+    for alternative in ${ax_cxx_compile_alternatives}; do
+      for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
+        cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
+        AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
+                       $cachevar,
+          [ac_save_CXX="$CXX"
+           CXX="$CXX $switch"
+           AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
+            [eval $cachevar=yes],
+            [eval $cachevar=no])
+           CXX="$ac_save_CXX"])
+        if eval test x\$$cachevar = xyes; then
+          CXX="$CXX $switch"
+          if test -n "$CXXCPP" ; then
+            CXXCPP="$CXXCPP $switch"
+          fi
+          ac_success=yes
+          break
+        fi
+      done
+      if test x$ac_success = xyes; then
+        break
+      fi
+    done
+  fi])
+  AC_LANG_POP([C++])
+  if test x$ax_cxx_compile_cxx$1_required = xtrue; then
+    if test x$ac_success = xno; then
+      AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
+    fi
+  fi
+  if test x$ac_success = xno; then
+    HAVE_CXX$1=0
+    AC_MSG_NOTICE([No compiler with C++$1 support was found])
+  else
+    HAVE_CXX$1=1
+    AC_DEFINE(HAVE_CXX$1,1,
+              [define if the compiler supports basic C++$1 syntax])
+  fi
+  AC_SUBST(HAVE_CXX$1)
+])
+
+
+dnl  Test body for checking C++11 support
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
+  _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
+)
+
+
+dnl  Test body for checking C++14 support
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
+  _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
+  _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
+)
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
+  _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
+  _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
+  _AX_CXX_COMPILE_STDCXX_testbody_new_in_17
+)
+
+dnl  Tests for new features in C++11
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
+
+// If the compiler admits that it is not ready for C++11, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201103L
+
+#error "This is not a C++11 compiler"
+
+#else
+
+namespace cxx11
+{
+
+  namespace test_static_assert
+  {
+
+    template <typename T>
+    struct check
+    {
+      static_assert(sizeof(int) <= sizeof(T), "not big enough");
+    };
+
+  }
+
+  namespace test_final_override
+  {
+
+    struct Base
+    {
+      virtual ~Base() {}
+      virtual void f() {}
+    };
+
+    struct Derived : public Base
+    {
+      virtual ~Derived() override {}
+      virtual void f() override {}
+    };
+
+  }
+
+  namespace test_double_right_angle_brackets
+  {
+
+    template < typename T >
+    struct check {};
+
+    typedef check<void> single_type;
+    typedef check<check<void>> double_type;
+    typedef check<check<check<void>>> triple_type;
+    typedef check<check<check<check<void>>>> quadruple_type;
+
+  }
+
+  namespace test_decltype
+  {
+
+    int
+    f()
+    {
+      int a = 1;
+      decltype(a) b = 2;
+      return a + b;
+    }
+
+  }
+
+  namespace test_type_deduction
+  {
+
+    template < typename T1, typename T2 >
+    struct is_same
+    {
+      static const bool value = false;
+    };
+
+    template < typename T >
+    struct is_same<T, T>
+    {
+      static const bool value = true;
+    };
+
+    template < typename T1, typename T2 >
+    auto
+    add(T1 a1, T2 a2) -> decltype(a1 + a2)
+    {
+      return a1 + a2;
+    }
+
+    int
+    test(const int c, volatile int v)
+    {
+      static_assert(is_same<int, decltype(0)>::value == true, "");
+      static_assert(is_same<int, decltype(c)>::value == false, "");
+      static_assert(is_same<int, decltype(v)>::value == false, "");
+      auto ac = c;
+      auto av = v;
+      auto sumi = ac + av + 'x';
+      auto sumf = ac + av + 1.0;
+      static_assert(is_same<int, decltype(ac)>::value == true, "");
+      static_assert(is_same<int, decltype(av)>::value == true, "");
+      static_assert(is_same<int, decltype(sumi)>::value == true, "");
+      static_assert(is_same<int, decltype(sumf)>::value == false, "");
+      static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
+      return (sumf > 0.0) ? sumi : add(c, v);
+    }
+
+  }
+
+  namespace test_noexcept
+  {
+
+    int f() { return 0; }
+    int g() noexcept { return 0; }
+
+    static_assert(noexcept(f()) == false, "");
+    static_assert(noexcept(g()) == true, "");
+
+  }
+
+  namespace test_constexpr
+  {
+
+    template < typename CharT >
+    unsigned long constexpr
+    strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
+    {
+      return *s ? strlen_c_r(s + 1, acc + 1) : acc;
+    }
+
+    template < typename CharT >
+    unsigned long constexpr
+    strlen_c(const CharT *const s) noexcept
+    {
+      return strlen_c_r(s, 0UL);
+    }
+
+    static_assert(strlen_c("") == 0UL, "");
+    static_assert(strlen_c("1") == 1UL, "");
+    static_assert(strlen_c("example") == 7UL, "");
+    static_assert(strlen_c("another\0example") == 7UL, "");
+
+  }
+
+  namespace test_rvalue_references
+  {
+
+    template < int N >
+    struct answer
+    {
+      static constexpr int value = N;
+    };
+
+    answer<1> f(int&)       { return answer<1>(); }
+    answer<2> f(const int&) { return answer<2>(); }
+    answer<3> f(int&&)      { return answer<3>(); }
+
+    void
+    test()
+    {
+      int i = 0;
+      const int c = 0;
+      static_assert(decltype(f(i))::value == 1, "");
+      static_assert(decltype(f(c))::value == 2, "");
+      static_assert(decltype(f(0))::value == 3, "");
+    }
+
+  }
+
+  namespace test_uniform_initialization
+  {
+
+    struct test
+    {
+      static const int zero {};
+      static const int one {1};
+    };
+
+    static_assert(test::zero == 0, "");
+    static_assert(test::one == 1, "");
+
+  }
+
+  namespace test_lambdas
+  {
+
+    void
+    test1()
+    {
+      auto lambda1 = [](){};
+      auto lambda2 = lambda1;
+      lambda1();
+      lambda2();
+    }
+
+    int
+    test2()
+    {
+      auto a = [](int i, int j){ return i + j; }(1, 2);
+      auto b = []() -> int { return '0'; }();
+      auto c = [=](){ return a + b; }();
+      auto d = [&](){ return c; }();
+      auto e = [a, &b](int x) mutable {
+        const auto identity = [](int y){ return y; };
+        for (auto i = 0; i < a; ++i)
+          a += b--;
+        return x + identity(a + b);
+      }(0);
+      return a + b + c + d + e;
+    }
+
+    int
+    test3()
+    {
+      const auto nullary = [](){ return 0; };
+      const auto unary = [](int x){ return x; };
+      using nullary_t = decltype(nullary);
+      using unary_t = decltype(unary);
+      const auto higher1st = [](nullary_t f){ return f(); };
+      const auto higher2nd = [unary](nullary_t f1){
+        return [unary, f1](unary_t f2){ return f2(unary(f1())); };
+      };
+      return higher1st(nullary) + higher2nd(nullary)(unary);
+    }
+
+  }
+
+  namespace test_variadic_templates
+  {
+
+    template <int...>
+    struct sum;
+
+    template <int N0, int... N1toN>
+    struct sum<N0, N1toN...>
+    {
+      static constexpr auto value = N0 + sum<N1toN...>::value;
+    };
+
+    template <>
+    struct sum<>
+    {
+      static constexpr auto value = 0;
+    };
+
+    static_assert(sum<>::value == 0, "");
+    static_assert(sum<1>::value == 1, "");
+    static_assert(sum<23>::value == 23, "");
+    static_assert(sum<1, 2>::value == 3, "");
+    static_assert(sum<5, 5, 11>::value == 21, "");
+    static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
+
+  }
+
+  // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
+  // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
+  // because of this.
+  namespace test_template_alias_sfinae
+  {
+
+    struct foo {};
+
+    template<typename T>
+    using member = typename T::member_type;
+
+    template<typename T>
+    void func(...) {}
+
+    template<typename T>
+    void func(member<T>*) {}
+
+    void test();
+
+    void test() { func<foo>(0); }
+
+  }
+
+}  // namespace cxx11
+
+#endif  // __cplusplus >= 201103L
+
+]])
+
+
+dnl  Tests for new features in C++14
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
+
+// If the compiler admits that it is not ready for C++14, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201402L
+
+#error "This is not a C++14 compiler"
+
+#else
+
+namespace cxx14
+{
+
+  namespace test_polymorphic_lambdas
+  {
+
+    int
+    test()
+    {
+      const auto lambda = [](auto&&... args){
+        const auto istiny = [](auto x){
+          return (sizeof(x) == 1UL) ? 1 : 0;
+        };
+        const int aretiny[] = { istiny(args)... };
+        return aretiny[0];
+      };
+      return lambda(1, 1L, 1.0f, '1');
+    }
+
+  }
+
+  namespace test_binary_literals
+  {
+
+    constexpr auto ivii = 0b0000000000101010;
+    static_assert(ivii == 42, "wrong value");
+
+  }
+
+  namespace test_generalized_constexpr
+  {
+
+    template < typename CharT >
+    constexpr unsigned long
+    strlen_c(const CharT *const s) noexcept
+    {
+      auto length = 0UL;
+      for (auto p = s; *p; ++p)
+        ++length;
+      return length;
+    }
+
+    static_assert(strlen_c("") == 0UL, "");
+    static_assert(strlen_c("x") == 1UL, "");
+    static_assert(strlen_c("test") == 4UL, "");
+    static_assert(strlen_c("another\0test") == 7UL, "");
+
+  }
+
+  namespace test_lambda_init_capture
+  {
+
+    int
+    test()
+    {
+      auto x = 0;
+      const auto lambda1 = [a = x](int b){ return a + b; };
+      const auto lambda2 = [a = lambda1(x)](){ return a; };
+      return lambda2();
+    }
+
+  }
+
+  namespace test_digit_separators
+  {
+
+    constexpr auto ten_million = 100'000'000;
+    static_assert(ten_million == 100000000, "");
+
+  }
+
+  namespace test_return_type_deduction
+  {
+
+    auto f(int& x) { return x; }
+    decltype(auto) g(int& x) { return x; }
+
+    template < typename T1, typename T2 >
+    struct is_same
+    {
+      static constexpr auto value = false;
+    };
+
+    template < typename T >
+    struct is_same<T, T>
+    {
+      static constexpr auto value = true;
+    };
+
+    int
+    test()
+    {
+      auto x = 0;
+      static_assert(is_same<int, decltype(f(x))>::value, "");
+      static_assert(is_same<int&, decltype(g(x))>::value, "");
+      return x;
+    }
+
+  }
+
+}  // namespace cxx14
+
+#endif  // __cplusplus >= 201402L
+
+]])
+
+
+dnl  Tests for new features in C++17
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
+
+// If the compiler admits that it is not ready for C++17, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201703L
+
+#error "This is not a C++17 compiler"
+
+#else
+
+#include <initializer_list>
+#include <utility>
+#include <type_traits>
+
+namespace cxx17
+{
+
+  namespace test_constexpr_lambdas
+  {
+
+    constexpr int foo = [](){return 42;}();
+
+  }
+
+  namespace test::nested_namespace::definitions
+  {
+
+  }
+
+  namespace test_fold_expression
+  {
+
+    template<typename... Args>
+    int multiply(Args... args)
+    {
+      return (args * ... * 1);
+    }
+
+    template<typename... Args>
+    bool all(Args... args)
+    {
+      return (args && ...);
+    }
+
+  }
+
+  namespace test_extended_static_assert
+  {
+
+    static_assert (true);
+
+  }
+
+  namespace test_auto_brace_init_list
+  {
+
+    auto foo = {5};
+    auto bar {5};
+
+    static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
+    static_assert(std::is_same<int, decltype(bar)>::value);
+  }
+
+  namespace test_typename_in_template_template_parameter
+  {
+
+    template<template<typename> typename X> struct D;
+
+  }
+
+  namespace test_fallthrough_nodiscard_maybe_unused_attributes
+  {
+
+    int f1()
+    {
+      return 42;
+    }
+
+    [[nodiscard]] int f2()
+    {
+      [[maybe_unused]] auto unused = f1();
+
+      switch (f1())
+      {
+      case 17:
+        f1();
+        [[fallthrough]];
+      case 42:
+        f1();
+      }
+      return f1();
+    }
+
+  }
+
+  namespace test_extended_aggregate_initialization
+  {
+
+    struct base1
+    {
+      int b1, b2 = 42;
+    };
+
+    struct base2
+    {
+      base2() {
+        b3 = 42;
+      }
+      int b3;
+    };
+
+    struct derived : base1, base2
+    {
+        int d;
+    };
+
+    derived d1 {{1, 2}, {}, 4};  // full initialization
+    derived d2 {{}, {}, 4};      // value-initialized bases
+
+  }
+
+  namespace test_general_range_based_for_loop
+  {
+
+    struct iter
+    {
+      int i;
+
+      int& operator* ()
+      {
+        return i;
+      }
+
+      const int& operator* () const
+      {
+        return i;
+      }
+
+      iter& operator++()
+      {
+        ++i;
+        return *this;
+      }
+    };
+
+    struct sentinel
+    {
+      int i;
+    };
+
+    bool operator== (const iter& i, const sentinel& s)
+    {
+      return i.i == s.i;
+    }
+
+    bool operator!= (const iter& i, const sentinel& s)
+    {
+      return !(i == s);
+    }
+
+    struct range
+    {
+      iter begin() const
+      {
+        return {0};
+      }
+
+      sentinel end() const
+      {
+        return {5};
+      }
+    };
+
+    void f()
+    {
+      range r {};
+
+      for (auto i : r)
+      {
+        [[maybe_unused]] auto v = i;
+      }
+    }
+
+  }
+
+  namespace test_lambda_capture_asterisk_this_by_value
+  {
+
+    struct t
+    {
+      int i;
+      int foo()
+      {
+        return [*this]()
+        {
+          return i;
+        }();
+      }
+    };
+
+  }
+
+  namespace test_enum_class_construction
+  {
+
+    enum class byte : unsigned char
+    {};
+
+    byte foo {42};
+
+  }
+
+  namespace test_constexpr_if
+  {
+
+    template <bool cond>
+    int f ()
+    {
+      if constexpr(cond)
+      {
+        return 13;
+      }
+      else
+      {
+        return 42;
+      }
+    }
+
+  }
+
+  namespace test_selection_statement_with_initializer
+  {
+
+    int f()
+    {
+      return 13;
+    }
+
+    int f2()
+    {
+      if (auto i = f(); i > 0)
+      {
+        return 3;
+      }
+
+      switch (auto i = f(); i + 4)
+      {
+      case 17:
+        return 2;
+
+      default:
+        return 1;
+      }
+    }
+
+  }
+
+  namespace test_template_argument_deduction_for_class_templates
+  {
+
+    template <typename T1, typename T2>
+    struct pair
+    {
+      pair (T1 p1, T2 p2)
+        : m1 {p1},
+          m2 {p2}
+      {}
+
+      T1 m1;
+      T2 m2;
+    };
+
+    void f()
+    {
+      [[maybe_unused]] auto p = pair{13, 42u};
+    }
+
+  }
+
+  namespace test_non_type_auto_template_parameters
+  {
+
+    template <auto n>
+    struct B
+    {};
+
+    B<5> b1;
+    B<'a'> b2;
+
+  }
+
+  namespace test_structured_bindings
+  {
+
+    int arr[2] = { 1, 2 };
+    std::pair<int, int> pr = { 1, 2 };
+
+    auto f1() -> int(&)[2]
+    {
+      return arr;
+    }
+
+    auto f2() -> std::pair<int, int>&
+    {
+      return pr;
+    }
+
+    struct S
+    {
+      int x1 : 2;
+      volatile double y1;
+    };
+
+    S f3()
+    {
+      return {};
+    }
+
+    auto [ x1, y1 ] = f1();
+    auto& [ xr1, yr1 ] = f1();
+    auto [ x2, y2 ] = f2();
+    auto& [ xr2, yr2 ] = f2();
+    const auto [ x3, y3 ] = f3();
+
+  }
+
+  namespace test_exception_spec_type_system
+  {
+
+    struct Good {};
+    struct Bad {};
+
+    void g1() noexcept;
+    void g2();
+
+    template<typename T>
+    Bad
+    f(T*, T*);
+
+    template<typename T1, typename T2>
+    Good
+    f(T1*, T2*);
+
+    static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
+
+  }
+
+  namespace test_inline_variables
+  {
+
+    template<class T> void f(T)
+    {}
+
+    template<class T> inline T g(T)
+    {
+      return T{};
+    }
+
+    template<> inline void f<>(int)
+    {}
+
+    template<> int g<>(int)
+    {
+      return 5;
+    }
+
+  }
+
+}  // namespace cxx17
+
+#endif  // __cplusplus < 201703L
+
+]])
diff --git a/src/keys/treekeyidx.cpp b/src/keys/treekeyidx.cpp
index c4716868..22a7e4c1 100644
--- a/src/keys/treekeyidx.cpp
+++ b/src/keys/treekeyidx.cpp
@@ -22,6 +22,7 @@
 
 
 #include <treekeyidx.h>
+#include <cstdint>
 #include <fcntl.h>
 #include <stdio.h>
 #include <errno.h>
@@ -177,7 +178,7 @@ bool TreeKeyIdx::nextSibling() {
 
 bool TreeKeyIdx::previousSibling() {
 	TreeNode iterator;
-	__s32 target = currentNode.offset;
+	int32_t target = currentNode.offset;
 	if (currentNode.parent > -1) {
 		getTreeNodeFromIdxOffset(currentNode.parent, &iterator);
 		getTreeNodeFromIdxOffset(iterator.firstChild, &iterator);
@@ -207,10 +208,10 @@ void TreeKeyIdx::append() {
 		while (lastSib.next > -1) {
 			getTreeNodeFromIdxOffset(lastSib.next, &lastSib);
 		}
-		__u32 idxOffset = (__u32)idxfd->seek(0, SEEK_END);
+		uint32_t idxOffset = (uint32_t)idxfd->seek(0, SEEK_END);
 		lastSib.next = idxOffset;
 		saveTreeNodeOffsets(&lastSib);
-		__u32 parent = currentNode.parent;
+		uint32_t parent = currentNode.parent;
 		currentNode.clear();
 		currentNode.offset = idxOffset;
 		currentNode.parent = parent;
@@ -224,10 +225,10 @@ void TreeKeyIdx::appendChild() {
 		append();
 	}
 	else {
-		__u32 idxOffset = (__u32)idxfd->seek(0, SEEK_END);
+		uint32_t idxOffset = (uint32_t)idxfd->seek(0, SEEK_END);
 		currentNode.firstChild = idxOffset;
 		saveTreeNodeOffsets(&currentNode);
-		__u32 parent = currentNode.offset;
+		uint32_t parent = currentNode.offset;
 		currentNode.clear();
 		currentNode.offset = idxOffset;
 		currentNode.parent = parent;
@@ -257,7 +258,7 @@ void TreeKeyIdx::remove() {
 		}
 		if (!done) {
 			TreeNode iterator;
-			__s32 target = currentNode.offset;
+			int32_t target = currentNode.offset;
 			if (currentNode.parent > -1) {
 				getTreeNodeFromIdxOffset(currentNode.parent, &iterator);
 				getTreeNodeFromIdxOffset(iterator.firstChild, &iterator);
@@ -331,8 +332,8 @@ signed char TreeKeyIdx::create(const char *ipath) {
 void TreeKeyIdx::getTreeNodeFromDatOffset(long ioffset, TreeNode *node) const {
 	unsnappedKeyText = "";
 	char ch;
-	__s32  tmp;
-	__u16  tmp2;
+	int32_t  tmp;
+	uint16_t  tmp2;
 
 	if (datfd && datfd->getFd() >= 0) {
 
@@ -379,7 +380,7 @@ void TreeKeyIdx::getTreeNodeFromDatOffset(long ioffset, TreeNode *node) const {
 
 char TreeKeyIdx::getTreeNodeFromIdxOffset(long ioffset, TreeNode *node) const {
 	unsnappedKeyText = "";
-	__u32 offset;
+	uint32_t offset;
 	char error = KEYERR_OUTOFBOUNDS;
 	
 	if (ioffset < 0) {
@@ -387,7 +388,7 @@ char TreeKeyIdx::getTreeNodeFromIdxOffset(long ioffset, TreeNode *node) const {
 		error = 77;	// out of bounds but still position to 0;
 	}
 
-	node->offset = (__s32)ioffset;
+	node->offset = (int32_t)ioffset;
 	if (idxfd && idxfd->getFd() >= 0) {
 		idxfd->seek(ioffset, SEEK_SET);
 		if (idxfd->read(&offset, 4) == 4) {
@@ -421,13 +422,13 @@ void TreeKeyIdx::setOffset(unsigned long offset) {
 void TreeKeyIdx::saveTreeNodeOffsets(TreeNode *node) {
 	unsnappedKeyText = "";
 	long datOffset = 0;
-	__s32 tmp;
+	int32_t tmp;
 
 	if (idxfd && idxfd->getFd() >= 0) {
 		idxfd->seek(node->offset, SEEK_SET);
 		if (idxfd->read(&tmp, 4) != 4) {
 			datOffset = datfd->seek(0, SEEK_END);
-			tmp = (__s32)archtosword32(datOffset);
+			tmp = (int32_t)archtosword32(datOffset);
 			idxfd->write(&tmp, 4);
 		}
 		else {
@@ -435,13 +436,13 @@ void TreeKeyIdx::saveTreeNodeOffsets(TreeNode *node) {
 			datfd->seek(datOffset, SEEK_SET);
 		}
 
-		tmp = (__s32)archtosword32(node->parent);
+		tmp = (int32_t)archtosword32(node->parent);
 		datfd->write(&tmp, 4);
 
-		tmp = (__s32)archtosword32(node->next);
+		tmp = (int32_t)archtosword32(node->next);
 		datfd->write(&tmp, 4);
 
-		tmp = (__s32)archtosword32(node->firstChild);
+		tmp = (int32_t)archtosword32(node->firstChild);
 		datfd->write(&tmp, 4);
 	}
 }
@@ -488,12 +489,12 @@ void TreeKeyIdx::copyFrom(const TreeKeyIdx &ikey) {
 
 void TreeKeyIdx::saveTreeNode(TreeNode *node) {
 	long datOffset = 0;
-	__s32 tmp;
+	int32_t tmp;
 	if (idxfd && idxfd->getFd() >= 0) {
 
 		idxfd->seek(node->offset, SEEK_SET);
 		datOffset = datfd->seek(0, SEEK_END);
-		tmp = (__s32)archtosword32(datOffset);
+		tmp = (int32_t)archtosword32(datOffset);
 		idxfd->write(&tmp, 4);
 
 		saveTreeNodeOffsets(node);
@@ -502,7 +503,7 @@ void TreeKeyIdx::saveTreeNode(TreeNode *node) {
 		char null = 0;
 		datfd->write(&null, 1);
 
-		__u16 tmp2 = archtosword16(node->dsize);
+		uint16_t tmp2 = archtosword16(node->dsize);
 		datfd->write(&tmp2, 2);
 
 		if (node->dsize) {
diff --git a/src/keys/versekey.cpp b/src/keys/versekey.cpp
index 8d9612d7..f8239abd 100644
--- a/src/keys/versekey.cpp
+++ b/src/keys/versekey.cpp
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <ctype.h>
 
+#include <cstdint>
 #include <utilstr.h>
 #include <stringmgr.h>
 #include <swkey.h>
@@ -776,7 +777,7 @@ terminate_range:
 					lastKey->setPosition(TOP);
 					tmpListKey << *lastKey;
 					((VerseKey *)tmpListKey.getElement())->setAutoNormalize(isAutoNormalize());
-					tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+					tmpListKey.getElement()->userData = (uint64_t)(bufStart+(buf-iBuf.c_str()));
 				}
 				else {
 					if (!dash) { 	// if last separator was not a dash just add
@@ -790,7 +791,7 @@ terminate_range:
 							*lastKey = TOP;
 							tmpListKey << *lastKey;
 							((VerseKey *)tmpListKey.getElement())->setAutoNormalize(isAutoNormalize());
-							tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+							tmpListKey.getElement()->userData = (uint64_t)(bufStart+(buf-iBuf.c_str()));
 						}
 						else {
 							bool f = false;
@@ -805,7 +806,7 @@ terminate_range:
 							*lastKey = TOP;
 							tmpListKey << *lastKey;
 							((VerseKey *)tmpListKey.getElement())->setAutoNormalize(isAutoNormalize());
-							tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+							tmpListKey.getElement()->userData = (uint64_t)(bufStart+(buf-iBuf.c_str()));
 						}
 					}
 					else	if (expandRange) {
@@ -818,7 +819,7 @@ terminate_range:
 							newElement->setUpperBound(*curKey);
 							*lastKey = *curKey;
 							*newElement = TOP;
-							tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+							tmpListKey.getElement()->userData = (uint64_t)(bufStart+(buf-iBuf.c_str()));
 						}
 					}
 				}
@@ -1049,7 +1050,7 @@ terminate_range:
 			lastKey->setLowerBound(*curKey);
 			*lastKey = TOP;
 			tmpListKey << *lastKey;
-			tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+			tmpListKey.getElement()->userData = (uint64_t)(bufStart+(buf-iBuf.c_str()));
 		}
 		else {
 			if (!dash) { 	// if last separator was not a dash just add
@@ -1062,7 +1063,7 @@ terminate_range:
 					lastKey->setUpperBound(*curKey);
 					*lastKey = TOP;
 					tmpListKey << *lastKey;
-					tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+					tmpListKey.getElement()->userData = (uint64_t)(bufStart+(buf-iBuf.c_str()));
 				}
 				else {
 					bool f = false;
@@ -1076,7 +1077,7 @@ terminate_range:
 					lastKey->setUpperBound(*curKey);
 					*lastKey = TOP;
 					tmpListKey << *lastKey;
-					tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+					tmpListKey.getElement()->userData = (uint64_t)(bufStart+(buf-iBuf.c_str()));
 				}
 			}
 			else if (expandRange) {
@@ -1088,7 +1089,7 @@ terminate_range:
 						*curKey = MAXVERSE;
 					newElement->setUpperBound(*curKey);
 					*newElement = TOP;
-					tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+					tmpListKey.getElement()->userData = (uint64_t)(bufStart+(buf-iBuf.c_str()));
 				}
 			}
 		}
diff --git a/src/mgr/stringmgr.cpp b/src/mgr/stringmgr.cpp
index a88fa439..c371e127 100644
--- a/src/mgr/stringmgr.cpp
+++ b/src/mgr/stringmgr.cpp
@@ -20,6 +20,7 @@
  *
  */
 
+#include <cstdint>
 #include <ctype.h>
 #include <stringmgr.h>
 #include <swlog.h>
@@ -145,10 +146,10 @@ class ICUStringMgr : public StringMgr {
 public:
 	virtual char *upperUTF8(char *, unsigned int maxlen = 0) const;
 	virtual char *lowerUTF8(char *, unsigned int maxlen = 0) const;
-	virtual bool isUpper(__u32 character) const;
-	virtual bool isLower(__u32 character) const;
-	virtual bool isDigit(__u32 character) const;
-	virtual bool isAlpha(__u32 character) const;
+	virtual bool isUpper(uint32_t character) const;
+	virtual bool isLower(uint32_t character) const;
+	virtual bool isDigit(uint32_t character) const;
+	virtual bool isAlpha(uint32_t character) const;
 	
 protected:
 	virtual bool supportsUnicode() const { return true; };
@@ -276,16 +277,16 @@ char *StringMgr::lowerUTF8(char *t, unsigned int maxlen) const {
 	return t;
 }
 
-bool StringMgr::isUpper(__u32 character) const {
+bool StringMgr::isUpper(uint32_t character) const {
 	return isupper(character);
 }
-bool StringMgr::isLower(__u32 character) const {
+bool StringMgr::isLower(uint32_t character) const {
 	return islower(character);
 }
-bool StringMgr::isDigit(__u32 character) const {
+bool StringMgr::isDigit(uint32_t character) const {
 	return isdigit(character);
 }
-bool StringMgr::isAlpha(__u32 character) const {
+bool StringMgr::isAlpha(uint32_t character) const {
 	return isalpha(character);
 }
 
@@ -389,16 +390,16 @@ char *ICUStringMgr::lowerUTF8(char *buf, unsigned int maxlen) const {
 	return ret;
 }
 
-bool ICUStringMgr::isUpper(__u32 character) const {
+bool ICUStringMgr::isUpper(uint32_t character) const {
 	return u_isupper(character);
 }
-bool ICUStringMgr::isLower(__u32 character) const {
+bool ICUStringMgr::isLower(uint32_t character) const {
 	return u_islower(character);
 }
-bool ICUStringMgr::isDigit(__u32 character) const {
+bool ICUStringMgr::isDigit(uint32_t character) const {
 	return u_isdigit(character);
 }
-bool ICUStringMgr::isAlpha(__u32 character) const {
+bool ICUStringMgr::isAlpha(uint32_t character) const {
 	return u_isalpha(character);
 }
 	
diff --git a/src/modules/comments/rawfiles/rawfiles.cpp b/src/modules/comments/rawfiles/rawfiles.cpp
index bfd3e1da..9ae60b25 100644
--- a/src/modules/comments/rawfiles/rawfiles.cpp
+++ b/src/modules/comments/rawfiles/rawfiles.cpp
@@ -22,6 +22,7 @@
  *
  */
 
+#include <cstdint>
 #include <ctype.h>
 #include <stdio.h>
 #include <fcntl.h>
@@ -187,7 +188,7 @@ void RawFiles::deleteEntry() {
 
 const char *RawFiles::getNextFilename() {
 	static SWBuf incfile;
-	__u32 number = 0;
+	uint32_t number = 0;
 	FileDesc *datafile;
 
 	incfile.setFormatted("%s/incfile", path);
@@ -213,7 +214,7 @@ const char *RawFiles::getNextFilename() {
 char RawFiles::createModule(const char *path) {
 	char *incfile = new char [ strlen (path) + 16 ];
 
-	__u32 zero = 0;
+	uint32_t zero = 0;
 	zero = archtosword32(zero);
 
 	FileDesc *datafile;
diff --git a/src/modules/common/entriesblk.cpp b/src/modules/common/entriesblk.cpp
index c2c02e41..e9aa3ee7 100644
--- a/src/modules/common/entriesblk.cpp
+++ b/src/modules/common/entriesblk.cpp
@@ -20,6 +20,7 @@
  *
  */
 
+#include <cstdint>
 #include <entriesblk.h>
 #include <stdlib.h>
 #include <string.h>
@@ -37,13 +38,13 @@ EntriesBlock::EntriesBlock(const char *iBlock, unsigned long size) {
 		memcpy(block, iBlock, size);
 	}
 	else {
-		block = (char *)calloc(1, sizeof(__u32));
+		block = (char *)calloc(1, sizeof(uint32_t));
 	}
 }
 
 
 EntriesBlock::EntriesBlock() {
-	block = (char *)calloc(1, sizeof(__u32));
+	block = (char *)calloc(1, sizeof(uint32_t));
 }
 
 
@@ -53,22 +54,22 @@ EntriesBlock::~EntriesBlock() {
 
 
 void EntriesBlock::setCount(int count) {
-	__u32 rawCount = archtosword32(count);
-	memcpy(block, &rawCount, sizeof(__u32));
+	uint32_t rawCount = archtosword32(count);
+	memcpy(block, &rawCount, sizeof(uint32_t));
 }
 
 
 int EntriesBlock::getCount() {
-	__u32 count = 0;
-	memcpy(&count, block, sizeof(__u32));
+	uint32_t count = 0;
+	memcpy(&count, block, sizeof(uint32_t));
 	count = swordtoarch32(count);
 	return count;
 }
 
 
 void EntriesBlock::getMetaEntry(int index, unsigned long *offset, unsigned long *size) {
-	__u32 rawOffset = 0;
-	__u32 rawSize = 0;
+	uint32_t rawOffset = 0;
+	uint32_t rawSize = 0;
 	*offset = 0;
 	*size = 0;
 	if (index >= getCount())	// assert index < count
@@ -84,8 +85,8 @@ void EntriesBlock::getMetaEntry(int index, unsigned long *offset, unsigned long
 
 
 void EntriesBlock::setMetaEntry(int index, unsigned long offset, unsigned long size) {
-	__u32 rawOffset = (__u32)archtosword32(offset);
-	__u32 rawSize = (__u32)archtosword32(size);
+	uint32_t rawOffset = (uint32_t)archtosword32(offset);
+	uint32_t rawSize = (uint32_t)archtosword32(size);
 
 	if (index >= getCount())	// assert index < count
 		return;
diff --git a/src/modules/common/rawstr.cpp b/src/modules/common/rawstr.cpp
index 0541b5c3..7bd2d8c7 100644
--- a/src/modules/common/rawstr.cpp
+++ b/src/modules/common/rawstr.cpp
@@ -23,6 +23,7 @@
  *
  */
 
+#include <cstdint>
 #include <stdio.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -145,7 +146,7 @@ void RawStr::getIDXBufDat(long ioffset, char **buf) const
 
 void RawStr::getIDXBuf(long ioffset, char **buf) const
 {
-	__u32 offset;
+	uint32_t offset;
 	
 	if (idxfd && idxfd->getFd() >= 0) {
 		idxfd->seek(ioffset, SEEK_SET);
@@ -170,7 +171,7 @@ void RawStr::getIDXBuf(long ioffset, char **buf) const
  * RET: error status -1 general error; -2 new file
  */
 
-signed char RawStr::findOffset(const char *ikey, __u32 *start, __u16 *size, long away, __u32 *idxoff) const
+signed char RawStr::findOffset(const char *ikey, uint32_t *start, uint16_t *size, long away, uint32_t *idxoff) const
 {
 	char *trybuf, *maxbuf, *key = 0, quitflag = 0;
 	signed char retval = -1;
@@ -239,13 +240,13 @@ signed char RawStr::findOffset(const char *ikey, __u32 *start, __u16 *size, long
 
 		idxfd->seek(tryoff, SEEK_SET);
 
-		__u32 tmpStart;
-		__u16 tmpSize;
+		uint32_t tmpStart;
+		uint16_t tmpSize;
 		*start = *size = tmpStart = tmpSize = 0;
 		idxfd->read(&tmpStart, 4);
 		idxfd->read(&tmpSize, 2);
 		if (idxoff)
-			*idxoff = (__u32)tryoff;
+			*idxoff = (uint32_t)tryoff;
 
 		*start = swordtoarch32(tmpStart);
 		*size  = swordtoarch16(tmpSize);
@@ -264,17 +265,17 @@ signed char RawStr::findOffset(const char *ikey, __u32 *start, __u16 *size, long
 			if (bad) {
 				if(!awayFromSubstrCheck)
 					retval = -1;
-				*start = (__u32)laststart;
+				*start = (uint32_t)laststart;
 				*size = lastsize;
 				tryoff = lasttry;
 				if (idxoff)
-					*idxoff = (__u32)tryoff;
+					*idxoff = (uint32_t)tryoff;
 				break;
 			}
 			idxfd->read(&tmpStart, 4);
 			idxfd->read(&tmpSize, 2);
 			if (idxoff)
-				*idxoff = (__u32)tryoff;
+				*idxoff = (uint32_t)tryoff;
 
 			*start = swordtoarch32(tmpStart);
 			*size  = swordtoarch16(tmpSize);
@@ -306,12 +307,12 @@ signed char RawStr::findOffset(const char *ikey, __u32 *start, __u16 *size, long
  *
  */
 
-void RawStr::readText(__u32 istart, __u16 *isize, char **idxbuf, SWBuf &buf) const
+void RawStr::readText(uint32_t istart, uint16_t *isize, char **idxbuf, SWBuf &buf) const
 {
 	unsigned int ch;
 	char *idxbuflocal = 0;
 	getIDXBufDat(istart, &idxbuflocal);
-	__u32 start = istart;
+	uint32_t start = istart;
 
 	do {
 		if (*idxbuf)
@@ -368,12 +369,12 @@ void RawStr::readText(__u32 istart, __u16 *isize, char **idxbuf, SWBuf &buf) con
 void RawStr::doSetText(const char *ikey, const char *buf, long len)
 {
 
-	__u32 start, outstart;
-	__u32 idxoff;
-	__u32 endoff;
-	__s32 shiftSize;
-	__u16 size;
-	__u16 outsize;
+	uint32_t start, outstart;
+	uint32_t idxoff;
+	uint32_t endoff;
+	int32_t shiftSize;
+	uint16_t size;
+	uint16_t outsize;
 	char *tmpbuf = 0;
 	char *key = 0;
 	char *dbKey = 0;
@@ -426,7 +427,7 @@ void RawStr::doSetText(const char *ikey, const char *buf, long len)
 		while (true);	// while we're resolving links
 	}
 
-	endoff = (__u32)idxfd->seek(0, SEEK_END);
+	endoff = (uint32_t)idxfd->seek(0, SEEK_END);
 
 	shiftSize = endoff - idxoff;
 
@@ -442,7 +443,7 @@ void RawStr::doSetText(const char *ikey, const char *buf, long len)
 	memcpy(outbuf + size, buf, len);
 	size = outsize = size + (len);
 
-	start = outstart = (__u32)datfd->seek(0, SEEK_END);
+	start = outstart = (uint32_t)datfd->seek(0, SEEK_END);
 
 	outstart = archtosword32(start);
 	outsize  = archtosword16(size);
diff --git a/src/modules/common/rawstr4.cpp b/src/modules/common/rawstr4.cpp
index 2d49b3d7..675d00e9 100644
--- a/src/modules/common/rawstr4.cpp
+++ b/src/modules/common/rawstr4.cpp
@@ -23,6 +23,7 @@
  *
  */
 
+#include <cstdint>
 #include <stdio.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -145,7 +146,7 @@ void RawStr4::getIDXBufDat(long ioffset, char **buf) const
 
 void RawStr4::getIDXBuf(long ioffset, char **buf) const
 {
-	__u32 offset;
+	uint32_t offset;
 	
 	if ((unsigned long)idxfd > 0) {
 		idxfd->seek(ioffset, SEEK_SET);
@@ -179,7 +180,7 @@ void RawStr4::getIDXBuf(long ioffset, char **buf) const
  * RET: error status -1 general error; -2 new file
  */
 
-signed char RawStr4::findOffset(const char *ikey, __u32 *start, __u32 *size, long away, __u32 *idxoff) const
+signed char RawStr4::findOffset(const char *ikey, uint32_t *start, uint32_t *size, long away, uint32_t *idxoff) const
 {
 	char *trybuf, *maxbuf, *key = 0, quitflag = 0;
 	signed char retval = -1;
@@ -249,12 +250,12 @@ signed char RawStr4::findOffset(const char *ikey, __u32 *start, __u32 *size, lon
 
 		idxfd->seek(tryoff, SEEK_SET);
 
-		__u32 tmpStart, tmpSize;
+		uint32_t tmpStart, tmpSize;
 		*start = *size = tmpStart = tmpSize = 0;
 		idxfd->read(&tmpStart, 4);
 		idxfd->read(&tmpSize, 4);
 		if (idxoff)
-			*idxoff = (__u32)tryoff;
+			*idxoff = (uint32_t)tryoff;
 
 		*start = swordtoarch32(tmpStart);
 		*size  = swordtoarch32(tmpSize);
@@ -273,17 +274,17 @@ signed char RawStr4::findOffset(const char *ikey, __u32 *start, __u32 *size, lon
 			if (bad) {
 				if(!awayFromSubstrCheck)
 					retval = -1;
-				*start = (__u32)laststart;
-				*size = (__u32)lastsize;
+				*start = (uint32_t)laststart;
+				*size = (uint32_t)lastsize;
 				tryoff = lasttry;
 				if (idxoff)
-					*idxoff = (__u32)tryoff;
+					*idxoff = (uint32_t)tryoff;
 				break;
 			}
 			idxfd->read(&tmpStart, 4);
 			idxfd->read(&tmpSize, 4);
 			if (idxoff)
-				*idxoff = (__u32)tryoff;
+				*idxoff = (uint32_t)tryoff;
 
 			*start = swordtoarch32(tmpStart);
 			*size  = swordtoarch32(tmpSize);
@@ -315,12 +316,12 @@ signed char RawStr4::findOffset(const char *ikey, __u32 *start, __u32 *size, lon
  *
  */
 
-void RawStr4::readText(__u32 istart, __u32 *isize, char **idxbuf, SWBuf &buf) const
+void RawStr4::readText(uint32_t istart, uint32_t *isize, char **idxbuf, SWBuf &buf) const
 {
 	unsigned int ch;
 	char *idxbuflocal = 0;
 	getIDXBufDat(istart, &idxbuflocal);
-	__u32 start = istart;
+	uint32_t start = istart;
 
 	do {
 		if (*idxbuf)
@@ -376,12 +377,12 @@ void RawStr4::readText(__u32 istart, __u32 *isize, char **idxbuf, SWBuf &buf) co
 
 void RawStr4::doSetText(const char *ikey, const char *buf, long len) {
 
-	__u32 start, outstart;
-	__u32 idxoff;
-	__u32 endoff;
-	__s32 shiftSize;
-	__u32 size;
-	__u32 outsize;
+	uint32_t start, outstart;
+	uint32_t idxoff;
+	uint32_t endoff;
+	int32_t shiftSize;
+	uint32_t size;
+	uint32_t outsize;
 	char *tmpbuf = 0;
 	char *key = 0;
 	char *dbKey = 0;
@@ -434,7 +435,7 @@ void RawStr4::doSetText(const char *ikey, const char *buf, long len) {
 		while (true);	// while we're resolving links
 	}
 
-	endoff = (__u32)idxfd->seek(0, SEEK_END);
+	endoff = (uint32_t)idxfd->seek(0, SEEK_END);
 
 	shiftSize = endoff - idxoff;
 
@@ -448,9 +449,9 @@ void RawStr4::doSetText(const char *ikey, const char *buf, long len) {
 	sprintf(outbuf, "%s%c%c", key, 13, 10);
 	size = strlen(outbuf);
 	memcpy(outbuf + size, buf, len);
-	size = outsize = size + (__u32)len;
+	size = outsize = size + (uint32_t)len;
 
-	start = outstart = (__u32)datfd->seek(0, SEEK_END);
+	start = outstart = (uint32_t)datfd->seek(0, SEEK_END);
 
 	outstart = archtosword32(start);
 	outsize  = archtosword32(size);
diff --git a/src/modules/common/rawverse.cpp b/src/modules/common/rawverse.cpp
index 3e79b88d..04b52404 100644
--- a/src/modules/common/rawverse.cpp
+++ b/src/modules/common/rawverse.cpp
@@ -25,6 +25,7 @@
 
 
 
+#include <cstdint>
 #include <ctype.h>
 #include <stdio.h>
 #include <fcntl.h>
@@ -122,8 +123,8 @@ void RawVerse::findOffset(char testmt, long idxoff, long *start, unsigned short
 		
 	if (idxfp[testmt-1]->getFd() >= 0) {
 		idxfp[testmt-1]->seek(idxoff, SEEK_SET);
-		__s32 tmpStart;
-		__u16 tmpSize;
+		int32_t tmpStart;
+		uint16_t tmpSize;
 		idxfp[testmt-1]->read(&tmpStart, 4);
 		long len = idxfp[testmt-1]->read(&tmpSize, 2); 		// read size
 
@@ -177,8 +178,8 @@ void RawVerse::readText(char testmt, long start, unsigned short size, SWBuf &buf
 
 void RawVerse::doSetText(char testmt, long idxoff, const char *buf, long len)
 {
-	__s32 start;
-	__u16 size;
+	int32_t start;
+	uint16_t size;
 
 	idxoff *= 6;
 	if (!testmt)
@@ -186,7 +187,7 @@ void RawVerse::doSetText(char testmt, long idxoff, const char *buf, long len)
 
 	size = (len < 0) ? strlen(buf) : len;
 
-	start = (__s32)textfp[testmt-1]->seek(0, SEEK_END);
+	start = (int32_t)textfp[testmt-1]->seek(0, SEEK_END);
 	idxfp[testmt-1]->seek(idxoff, SEEK_SET);
 
 	if (size) {
@@ -217,8 +218,8 @@ void RawVerse::doSetText(char testmt, long idxoff, const char *buf, long len)
  */
 
 void RawVerse::doLinkEntry(char testmt, long destidxoff, long srcidxoff) {
-	__s32 start;
-	__u16 size;
+	int32_t start;
+	uint16_t size;
 
 	destidxoff *= 6;
 	srcidxoff  *= 6;
@@ -282,8 +283,8 @@ char RawVerse::createModule(const char *ipath, const char *v11n)
 	vk.setVersificationSystem(v11n);
 	vk.setIntros(1);
 
-	__s32 offset = 0;
-	__u16 size = 0;
+	int32_t offset = 0;
+	uint16_t size = 0;
 	offset = archtosword32(offset);
 	size = archtosword16(size);
 
diff --git a/src/modules/common/rawverse4.cpp b/src/modules/common/rawverse4.cpp
index 67a43d8f..b4dc1651 100644
--- a/src/modules/common/rawverse4.cpp
+++ b/src/modules/common/rawverse4.cpp
@@ -26,6 +26,7 @@
 
 
 
+#include <cstdint>
 #include <ctype.h>
 #include <stdio.h>
 #include <fcntl.h>
@@ -123,8 +124,8 @@ void RawVerse4::findOffset(char testmt, long idxoff, long *start, unsigned long
 		
 	if (idxfp[testmt-1]->getFd() >= 0) {
 		idxfp[testmt-1]->seek(idxoff, SEEK_SET);
-		__u32 tmpStart;
-		__u32 tmpSize;
+		uint32_t tmpStart;
+		uint32_t tmpSize;
 		idxfp[testmt-1]->read(&tmpStart, 4);
 		long len = idxfp[testmt-1]->read(&tmpSize, 4); 		// read size
 
@@ -178,16 +179,16 @@ void RawVerse4::readText(char testmt, long start, unsigned long size, SWBuf &buf
 
 void RawVerse4::doSetText(char testmt, long idxoff, const char *buf, long len)
 {
-	__u32 start;
-	__u32 size;
+	uint32_t start;
+	uint32_t size;
 
 	idxoff *= 8;
 	if (!testmt)
 		testmt = ((idxfp[1]) ? 1:2);
 
-	size = (__u32)((len < 0) ? strlen(buf) : len);
+	size = (uint32_t)((len < 0) ? strlen(buf) : len);
 
-	start = (__u32)textfp[testmt-1]->seek(0, SEEK_END);
+	start = (uint32_t)textfp[testmt-1]->seek(0, SEEK_END);
 	idxfp[testmt-1]->seek(idxoff, SEEK_SET);
 
 	if (size) {
@@ -218,8 +219,8 @@ void RawVerse4::doSetText(char testmt, long idxoff, const char *buf, long len)
  */
 
 void RawVerse4::doLinkEntry(char testmt, long destidxoff, long srcidxoff) {
-	__u32 start;
-	__u32 size;
+	uint32_t start;
+	uint32_t size;
 
 	destidxoff *= 8;
 	srcidxoff  *= 8;
@@ -282,8 +283,8 @@ char RawVerse4::createModule(const char *ipath, const char *v11n)
 	VerseKey vk;
 	vk.setVersificationSystem(v11n);
 	vk.setIntros(1);
-	__u32 offset = 0;
-	__u32 size = 0;
+	uint32_t offset = 0;
+	uint32_t size = 0;
 	offset = archtosword32(offset);
 	size   = archtosword32(size);
 
diff --git a/src/modules/common/zstr.cpp b/src/modules/common/zstr.cpp
index 324372da..55b3f6f3 100644
--- a/src/modules/common/zstr.cpp
+++ b/src/modules/common/zstr.cpp
@@ -23,6 +23,7 @@
  */
 
 
+#include <cstdint>
 #include <stdio.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -167,7 +168,7 @@ void zStr::getKeyFromDatOffset(long ioffset, char **buf) const
 
 void zStr::getKeyFromIdxOffset(long ioffset, char **buf) const
 {
-	__u32 offset;
+	uint32_t offset;
 	
 	if (idxfd && idxfd->getFd() >= 0) {
 		idxfd->seek(ioffset, SEEK_SET);
@@ -194,13 +195,13 @@ signed char zStr::findKeyIndex(const char *ikey, long *idxoff, long away) const
 {
 	char *maxbuf = 0, *trybuf = 0, *key = 0, quitflag = 0;
 	signed char retval = 0;
-	__s32 headoff, tailoff, tryoff = 0, maxoff = 0;
-	__u32 start, size;
+	int32_t headoff, tailoff, tryoff = 0, maxoff = 0;
+	uint32_t start, size;
 	int diff = 0;
 	bool awayFromSubstrCheck = false;
 
 	if (idxfd->getFd() >= 0) {
-		tailoff = maxoff = (__s32)idxfd->seek(0, SEEK_END) - IDXENTRYSIZE;
+		tailoff = maxoff = (int32_t)idxfd->seek(0, SEEK_END) - IDXENTRYSIZE;
 		if (*ikey) {
 			headoff = 0;
 			stdstr(&key, ikey, 3);
@@ -212,7 +213,7 @@ signed char zStr::findKeyIndex(const char *ikey, long *idxoff, long away) const
 			getKeyFromIdxOffset(maxoff, &maxbuf);
 
 			while (headoff < tailoff) {
-				tryoff = ((__s32)lastoff == -1) ? headoff + (((((tailoff / IDXENTRYSIZE) - (headoff / IDXENTRYSIZE))) / 2) * IDXENTRYSIZE) : (__s32)lastoff;
+				tryoff = ((int32_t)lastoff == -1) ? headoff + (((((tailoff / IDXENTRYSIZE) - (headoff / IDXENTRYSIZE))) / 2) * IDXENTRYSIZE) : (int32_t)lastoff;
 				lastoff = -1;
 
 				getKeyFromIdxOffset(tryoff, &trybuf);
@@ -268,9 +269,9 @@ signed char zStr::findKeyIndex(const char *ikey, long *idxoff, long away) const
 			*idxoff = tryoff;
 
 		while (away) {
-			__u32 laststart = start;
-			__u32 lastsize = size;
-			__s32 lasttry = tryoff;
+			uint32_t laststart = start;
+			uint32_t lastsize = size;
+			int32_t lasttry = tryoff;
 			tryoff += (away > 0) ? IDXENTRYSIZE : -IDXENTRYSIZE;
 
 			bool bad = false;
@@ -328,8 +329,8 @@ void zStr::getText(long offset, char **idxbuf, char **buf) const {
 	char *ch;
 	char *idxbuflocal = 0;
 	getKeyFromIdxOffset(offset, &idxbuflocal);
-	__u32 start;
-	__u32 size;
+	uint32_t start;
+	uint32_t size;
 
 	do {
 		idxfd->seek(offset, SEEK_SET);
@@ -368,16 +369,16 @@ void zStr::getText(long offset, char **idxbuf, char **buf) const {
 	while (true);	// while we're resolving links
 
 	if (idxbuflocal) {
-		__u32 localsize = (__u32)strlen(idxbuflocal);
+		uint32_t localsize = (uint32_t)strlen(idxbuflocal);
 		localsize = (localsize < (size - 1)) ? localsize : (size - 1);
 		strncpy(*idxbuf, idxbuflocal, localsize);
 		(*idxbuf)[localsize] = 0;
 		free(idxbuflocal);
 	}
-	__u32 block = 0;
-	__u32 entry = 0;
-	memmove(&block, *buf, sizeof(__u32));
-	memmove(&entry, *buf + sizeof(__u32), sizeof(__u32));
+	uint32_t block = 0;
+	uint32_t entry = 0;
+	memmove(&block, *buf, sizeof(uint32_t));
+	memmove(&entry, *buf + sizeof(uint32_t), sizeof(uint32_t));
 	block = swordtoarch32(block);
 	entry = swordtoarch32(entry);
 	getCompressedText(block, entry, buf);
@@ -391,10 +392,10 @@ void zStr::getText(long offset, char **idxbuf, char **buf) const {
 
 void zStr::getCompressedText(long block, long entry, char **buf) const {
 
-	__u32 size = 0;
+	uint32_t size = 0;
 
 	if (cacheBlockIndex != block) {
-		__u32 start = 0;
+		uint32_t start = 0;
 
 		zdxfd->seek(block * ZDXENTRYSIZE, SEEK_SET);
 		zdxfd->read(&start, 4);
@@ -418,7 +419,7 @@ void zStr::getCompressedText(long block, long entry, char **buf) const {
 		cacheBlock = new EntriesBlock(rawBuf, len);
 		cacheBlockIndex = block;
 	}
-	size = (__u32)cacheBlock->getEntrySize(entry);
+	size = (uint32_t)cacheBlock->getEntrySize(entry);
 	*buf = (*buf) ? (char *)realloc(*buf, size*2 + 1) : (char *)malloc(size*2 + 1);
 	strcpy(*buf, cacheBlock->getEntry(entry));
 }
@@ -436,11 +437,11 @@ void zStr::setText(const char *ikey, const char *buf, long len) {
 
 	static const char nl[] = {13, 10};
 
-	__u32 start, outstart;
-	__u32 size, outsize;
-	__s32 endoff;
+	uint32_t start, outstart;
+	uint32_t size, outsize;
+	int32_t endoff;
 	long idxoff = 0;
-	__s32 shiftSize;
+	int32_t shiftSize;
 	char *tmpbuf = 0;
 	char *key = 0;
 	char *dbKey = 0;
@@ -499,9 +500,9 @@ void zStr::setText(const char *ikey, const char *buf, long len) {
 		}
 	}
 
-	endoff = (__s32)idxfd->seek(0, SEEK_END);
+	endoff = (int32_t)idxfd->seek(0, SEEK_END);
 
-	shiftSize = endoff - (__s32)idxoff;
+	shiftSize = endoff - (int32_t)idxoff;
 
 	if (shiftSize > 0) {
 	        idxBytes = new char [ shiftSize ];
@@ -511,7 +512,7 @@ void zStr::setText(const char *ikey, const char *buf, long len) {
 
 	outbuf = new char [ len + strlen(key) + 5 ];
 	sprintf(outbuf, "%s%c%c", key, 13, 10);
-	size = (__u32)strlen(outbuf);
+	size = (uint32_t)strlen(outbuf);
 	if (len > 0) {	// NOT a link
 		if (!cacheBlock) {
 			flushCache();
@@ -523,20 +524,20 @@ void zStr::setText(const char *ikey, const char *buf, long len) {
 			cacheBlock = new EntriesBlock();
 			cacheBlockIndex = (zdxfd->seek(0, SEEK_END) / ZDXENTRYSIZE);
 		}
-		__u32 entry = cacheBlock->addEntry(buf);
+		uint32_t entry = cacheBlock->addEntry(buf);
 		cacheDirty = true;
-		outstart = (__u32)archtosword32(cacheBlockIndex);
+		outstart = (uint32_t)archtosword32(cacheBlockIndex);
 		outsize = archtosword32(entry);
-		memcpy (outbuf + size, &outstart, sizeof(__u32));
-		memcpy (outbuf + size + sizeof(__u32), &outsize, sizeof(__u32));
-		size += (sizeof(__u32) * 2);
+		memcpy (outbuf + size, &outstart, sizeof(uint32_t));
+		memcpy (outbuf + size + sizeof(uint32_t), &outsize, sizeof(uint32_t));
+		size += (sizeof(uint32_t) * 2);
 	}
 	else {	// link
 		memcpy(outbuf + size, buf, len);
 		size += len;
 	}
 
-	start = (__u32)datfd->seek(0, SEEK_END);
+	start = (uint32_t)datfd->seek(0, SEEK_END);
 
 	outstart = archtosword32(start);
 	outsize  = archtosword32(size);
@@ -593,9 +594,9 @@ void zStr::flushCache() const {
 
 	if (cacheBlock) {
 		if (cacheDirty) {
-			__u32 start = 0;
+			uint32_t start = 0;
 			unsigned long size = 0;
-			__u32 outstart = 0, outsize = 0;
+			uint32_t outstart = 0, outsize = 0;
 
 			const char *rawBuf = cacheBlock->getRawData(&size);
 			compressor->Buf(rawBuf, &size);
@@ -611,7 +612,7 @@ void zStr::flushCache() const {
 			unsigned long zdtSize = zdtfd->seek(0, SEEK_END);
 
 			if ((cacheBlockIndex * ZDXENTRYSIZE) > (zdxSize - ZDXENTRYSIZE)) {	// New Block
-				start = (__u32)zdtSize;
+				start = (uint32_t)zdtSize;
 			}
 			else {
 				zdxfd->seek(cacheBlockIndex * ZDXENTRYSIZE, SEEK_SET);
@@ -626,14 +627,14 @@ void zStr::flushCache() const {
 					size = outsize;
 				}
 				else {	// middle and bigger-- we have serious problems, for now let's put it at the end = lots of wasted space
-					start = (__u32)zdtSize;
+					start = (uint32_t)zdtSize;
 				}
 			}
 
 
 
 			outstart = archtosword32(start);
-			outsize  = archtosword32((__u32)size);
+			outsize  = archtosword32((uint32_t)size);
 
 			zdxfd->seek(cacheBlockIndex * ZDXENTRYSIZE, SEEK_SET);
 			zdtfd->seek(start, SEEK_SET);
diff --git a/src/modules/common/zverse.cpp b/src/modules/common/zverse.cpp
index d54c67d9..1a0a7c9d 100644
--- a/src/modules/common/zverse.cpp
+++ b/src/modules/common/zverse.cpp
@@ -25,6 +25,7 @@
 
 
 
+#include <cstdint>
 #include <ctype.h>
 #include <stdio.h>
 #include <fcntl.h>
@@ -149,9 +150,9 @@ zVerse::~zVerse()
 
 void zVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *size, unsigned long *buffnum) const
 {
-	__u32 ulBuffNum    = 0;	          // buffer number
-	__u32 ulVerseStart = 0;	       // verse offset within buffer
-	__u16 usVerseSize  = 0;	       // verse size
+	uint32_t ulBuffNum    = 0;	          // buffer number
+	uint32_t ulVerseStart = 0;	       // verse offset within buffer
+	uint16_t usVerseSize  = 0;	       // verse size
 	// set start to offset in
 	// set size to
 	// set
@@ -204,9 +205,9 @@ void zVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *s
  */
 
 void zVerse::zReadText(char testmt, long start, unsigned short size, unsigned long ulBuffNum, SWBuf &inBuf) const {
-	__u32 ulCompOffset = 0;	       // compressed buffer start
-	__u32 ulCompSize   = 0;	             // buffer size compressed
-	__u32 ulUnCompSize = 0;	          // buffer size uncompressed
+	uint32_t ulCompOffset = 0;	       // compressed buffer start
+	uint32_t ulCompSize   = 0;	             // buffer size compressed
+	uint32_t ulUnCompSize = 0;	          // buffer size uncompressed
 
 	if (!testmt) {
 		testmt = ((idxfp[0]) ? 1:2);
@@ -312,14 +313,14 @@ void zVerse::doSetText(char testmt, long idxoff, const char *buf, long len) {
 
 	dirtyCache = true;
 
-	__u32 start;
-	__u16 size;
-	__u32 outBufIdx = (__u32)cacheBufIdx;
+	uint32_t start;
+	uint16_t size;
+	uint32_t outBufIdx = (uint32_t)cacheBufIdx;
 
 	idxoff *= 10;
 	size = len;
 
-	start = (__u32)strlen(cacheBuf);
+	start = (uint32_t)strlen(cacheBuf);
 
 	if (!size)
 		start = outBufIdx = 0;
@@ -338,14 +339,14 @@ void zVerse::doSetText(char testmt, long idxoff, const char *buf, long len) {
 
 void zVerse::flushCache() const {
 	if (dirtyCache) {
-		__u32 idxoff;
-		__u32 start, outstart;
-		__u32 size, outsize;
-		__u32 zsize, outzsize;
+		uint32_t idxoff;
+		uint32_t start, outstart;
+		uint32_t size, outsize;
+		uint32_t zsize, outzsize;
 
-		idxoff = (__u32)cacheBufIdx * 12;
+		idxoff = (uint32_t)cacheBufIdx * 12;
 		if (cacheBuf) {
-			size = outsize = zsize = outzsize = (__u32)strlen(cacheBuf);
+			size = outsize = zsize = outzsize = (uint32_t)strlen(cacheBuf);
 			if (size) {
 	//			if (compressor) {
 	//				delete compressor;
@@ -354,16 +355,16 @@ void zVerse::flushCache() const {
 				compressor->Buf(cacheBuf);
 				unsigned long tmpSize;
 				compressor->zBuf(&tmpSize);
-				outzsize = zsize = (__u32)tmpSize;
+				outzsize = zsize = (uint32_t)tmpSize;
 
 				SWBuf buf;
 				buf.setSize(zsize + 5);
 				memcpy(buf.getRawData(), compressor->zBuf(&tmpSize), tmpSize);
-				outzsize = zsize = (__u32)tmpSize;
+				outzsize = zsize = (uint32_t)tmpSize;
 				buf.setSize(zsize);
 				rawZFilter(buf, 1); // 1 = encipher
 
-				start = outstart = (__u32)textfp[cacheTestament-1]->seek(0, SEEK_END);
+				start = outstart = (uint32_t)textfp[cacheTestament-1]->seek(0, SEEK_END);
 
 				outstart  = archtosword32(start);
 				outsize   = archtosword32(size);
@@ -392,9 +393,9 @@ void zVerse::flushCache() const {
  */
 
 void zVerse::doLinkEntry(char testmt, long destidxoff, long srcidxoff) {
-	__s32 bufidx;
-	__s32 start;
-	__u16 size;
+	int32_t bufidx;
+	int32_t start;
+	uint16_t size;
 
 	destidxoff *= 10;
 	srcidxoff  *= 10;
@@ -429,8 +430,8 @@ char zVerse::createModule(const char *ipath, int blockBound, const char *v11n)
 	char *buf = new char [ strlen (ipath) + 20 ];
 	char retVal = 0;
 	FileDesc *fd, *fd2;
-	__s32 offset = 0;
-	__s16 size = 0;
+	int32_t offset = 0;
+	int16_t size = 0;
 	VerseKey vk;
 
 	stdstr(&path, ipath);
diff --git a/src/modules/common/zverse4.cpp b/src/modules/common/zverse4.cpp
index c5f7d79b..2c842837 100644
--- a/src/modules/common/zverse4.cpp
+++ b/src/modules/common/zverse4.cpp
@@ -23,6 +23,7 @@
  *
  */
 
+#include <cstdint>
 #include <ctype.h>
 #include <stdio.h>
 #include <fcntl.h>
@@ -147,9 +148,9 @@ zVerse4::~zVerse4()
 
 void zVerse4::findOffset(char testmt, long idxoff, long *start, unsigned long *size, unsigned long *buffnum) const
 {
-	__u32 ulBuffNum    = 0;	          // buffer number
-	__u32 ulVerseStart = 0;	       // verse offset within buffer
-	__u32 usVerseSize  = 0;	       // verse size
+	uint32_t ulBuffNum    = 0;	          // buffer number
+	uint32_t ulVerseStart = 0;	       // verse offset within buffer
+	uint32_t usVerseSize  = 0;	       // verse size
 	// set start to offset in
 	// set size to
 	// set
@@ -202,9 +203,9 @@ void zVerse4::findOffset(char testmt, long idxoff, long *start, unsigned long *s
  */
 
 void zVerse4::zReadText(char testmt, long start, unsigned long size, unsigned long ulBuffNum, SWBuf &inBuf) const {
-	__u32 ulCompOffset = 0;	       // compressed buffer start
-	__u32 ulCompSize   = 0;	             // buffer size compressed
-	__u32 ulUnCompSize = 0;	          // buffer size uncompressed
+	uint32_t ulCompOffset = 0;	       // compressed buffer start
+	uint32_t ulCompSize   = 0;	             // buffer size compressed
+	uint32_t ulUnCompSize = 0;	          // buffer size uncompressed
 
 	if (!testmt) {
 		testmt = ((idxfp[0]) ? 1:2);
@@ -310,14 +311,14 @@ void zVerse4::doSetText(char testmt, long idxoff, const char *buf, long len) {
 
 	dirtyCache = true;
 
-	__u32 start;
-	__u32 size;
-	__u32 outBufIdx = (__u32)cacheBufIdx;
+	uint32_t start;
+	uint32_t size;
+	uint32_t outBufIdx = (uint32_t)cacheBufIdx;
 
 	idxoff *= 12;
-	size = (__u32)len;
+	size = (uint32_t)len;
 
-	start = (__u32)strlen(cacheBuf);
+	start = (uint32_t)strlen(cacheBuf);
 
 	if (!size)
 		start = outBufIdx = 0;
@@ -336,28 +337,28 @@ void zVerse4::doSetText(char testmt, long idxoff, const char *buf, long len) {
 
 void zVerse4::flushCache() const {
 	if (dirtyCache) {
-		__u32 idxoff;
-		__u32 start, outstart;
-		__u32 size, outsize;
-		__u32 zsize, outzsize;
+		uint32_t idxoff;
+		uint32_t start, outstart;
+		uint32_t size, outsize;
+		uint32_t zsize, outzsize;
 
-		idxoff = (__u32)cacheBufIdx * 12;
+		idxoff = (uint32_t)cacheBufIdx * 12;
 		if (cacheBuf) {
-			size = outsize = zsize = outzsize = (__u32)strlen(cacheBuf);
+			size = outsize = zsize = outzsize = (uint32_t)strlen(cacheBuf);
 			if (size) {
 				compressor->Buf(cacheBuf);
 				unsigned long tmpSize;
 				compressor->zBuf(&tmpSize);
-				outzsize = zsize = (__u32)tmpSize;
+				outzsize = zsize = (uint32_t)tmpSize;
 
 				SWBuf buf;
 				buf.setSize(zsize + 5);
 				memcpy(buf.getRawData(), compressor->zBuf(&tmpSize), tmpSize);
-				outzsize = zsize = (__u32)tmpSize;
+				outzsize = zsize = (uint32_t)tmpSize;
 				buf.setSize(zsize);
 				rawZFilter(buf, 1); // 1 = encipher
 
-				start = outstart = (__u32)textfp[cacheTestament-1]->seek(0, SEEK_END);
+				start = outstart = (uint32_t)textfp[cacheTestament-1]->seek(0, SEEK_END);
 
 				outstart  = archtosword32(start);
 				outsize   = archtosword32(size);
@@ -386,9 +387,9 @@ void zVerse4::flushCache() const {
  */
 
 void zVerse4::doLinkEntry(char testmt, long destidxoff, long srcidxoff) {
-	__s32 bufidx;
-	__s32 start;
-	__u32 size;
+	int32_t bufidx;
+	int32_t start;
+	uint32_t size;
 
 	destidxoff *= 12;
 	srcidxoff  *= 12;
@@ -423,8 +424,8 @@ char zVerse4::createModule(const char *ipath, int blockBound, const char *v11n)
 	char *buf = new char [ strlen (ipath) + 20 ];
 	char retVal = 0;
 	FileDesc *fd, *fd2;
-	__s32 offset = 0;
-	__s32 size = 0;
+	int32_t offset = 0;
+	int32_t size = 0;
 	VerseKey vk;
 
 	stdstr(&path, ipath);
diff --git a/src/modules/filters/rtfhtml.cpp b/src/modules/filters/rtfhtml.cpp
index c2cf73e0..39074393 100644
--- a/src/modules/filters/rtfhtml.cpp
+++ b/src/modules/filters/rtfhtml.cpp
@@ -21,6 +21,7 @@
  *
  */
 
+#include <cstdint>
 #include <stdlib.h>
 #include <rtfhtml.h>
 #include <swbuf.h>
@@ -53,8 +54,8 @@ char RTFHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
 				while (isdigit(*++end));
 				SWBuf num;
 				num.append(from, end-from);
-				__s16 n = atoi(num.c_str());
-				__u32 u = (__u16)n;
+				int16_t n = atoi(num.c_str());
+				uint32_t u = (uint16_t)n;
 				getUTF8FromUniChar(u, &text);
 				from += (end-from);
 				continue;
diff --git a/src/modules/filters/utf8greekaccents.cpp b/src/modules/filters/utf8greekaccents.cpp
index 9f235a7a..695aba1a 100644
--- a/src/modules/filters/utf8greekaccents.cpp
+++ b/src/modules/filters/utf8greekaccents.cpp
@@ -21,6 +21,7 @@
  *
  */
 
+#include <cstdint>
 #include <stdlib.h>
 #include <map>
 #include <stdio.h>
@@ -42,7 +43,7 @@ namespace {
 		return &oVals;
 	}
 
-	std::map<__u32, SWBuf> converters;
+	std::map<uint32_t, SWBuf> converters;
 	class converters_init {
 	public:
 		converters_init() {
@@ -350,9 +351,9 @@ char UTF8GreekAccents::processText(SWBuf &text, const SWKey *key, const SWModule
 		SWBuf orig = text;
 		const unsigned char* from = (unsigned char*)orig.c_str();
 		text = "";
-		map<__u32, SWBuf>::const_iterator it = converters.end();
+		map<uint32_t, SWBuf>::const_iterator it = converters.end();
 		while (*from) {		
-			__u32 ch = getUniCharFromUTF8(&from, true);
+			uint32_t ch = getUniCharFromUTF8(&from, true);
 			// if ch is bad, then convert to replacement char
 			if (!ch) ch = 0xFFFD;
 
diff --git a/src/modules/filters/utf8utf16.cpp b/src/modules/filters/utf8utf16.cpp
index 7cbfe596..0a5ad2ab 100644
--- a/src/modules/filters/utf8utf16.cpp
+++ b/src/modules/filters/utf8utf16.cpp
@@ -21,6 +21,7 @@
  */
 
 
+#include <cstdint>
 #include <utf8utf16.h>
 #include <utilstr.h>
 #include <swbuf.h>
@@ -43,25 +44,25 @@ char UTF8UTF16::processText(SWBuf &text, const SWKey *key, const SWModule *modul
 	text = "";
 	while (*from) {
 
-		__u32 ch = getUniCharFromUTF8(&from);
+		uint32_t ch = getUniCharFromUTF8(&from);
 
 		if (!ch) continue;	// invalid char
 
 		if (ch < 0x10000) {
 			text.setSize(text.size()+2);
-			*((__u16 *)(text.getRawData()+(text.size()-2))) = (__u16)ch;
+			*((uint16_t *)(text.getRawData()+(text.size()-2))) = (uint16_t)ch;
 		}
 		else {
-			__u16 utf16;
-			utf16 = (__s16)((ch - 0x10000) / 0x400 + 0xD800);
+			uint16_t utf16;
+			utf16 = (int16_t)((ch - 0x10000) / 0x400 + 0xD800);
 			text.setSize(text.size()+4);
-			*((__u16 *)(text.getRawData()+(text.size()-4))) = utf16;
-			utf16 = (__s16)((ch - 0x10000) % 0x400 + 0xDC00);
-			*((__u16 *)(text.getRawData()+(text.size()-2))) = utf16;
+			*((uint16_t *)(text.getRawData()+(text.size()-4))) = utf16;
+			utf16 = (int16_t)((ch - 0x10000) % 0x400 + 0xDC00);
+			*((uint16_t *)(text.getRawData()+(text.size()-2))) = utf16;
 		}
 	}
 	text.setSize(text.size()+2);
-	*((__u16 *)(text.getRawData()+(text.size()-2))) = (__u16)0;
+	*((uint16_t *)(text.getRawData()+(text.size()-2))) = (uint16_t)0;
 	text.setSize(text.size()-2);
 	   
 	return 0;
diff --git a/src/modules/genbook/rawgenbook/rawgenbook.cpp b/src/modules/genbook/rawgenbook/rawgenbook.cpp
index 4074cf9b..8df82e2e 100644
--- a/src/modules/genbook/rawgenbook/rawgenbook.cpp
+++ b/src/modules/genbook/rawgenbook/rawgenbook.cpp
@@ -23,6 +23,7 @@
 
 
 
+#include <cstdint>
 #include <stdio.h>
 #include <fcntl.h>
 
@@ -98,8 +99,8 @@ bool RawGenBook::isWritable() const {
 
 SWBuf &RawGenBook::getRawEntryBuf() const {
 
-	__u32 offset = 0;
-	__u32 size = 0;
+	uint32_t offset = 0;
+	uint32_t size = 0;
 
 	const TreeKey &key = getTreeKey();
 
@@ -133,8 +134,8 @@ SWBuf &RawGenBook::getRawEntryBuf() const {
 
 void RawGenBook::setEntry(const char *inbuf, long len) {
 
-	__u32 offset = (__u32)archtosword32(bdtfd->seek(0, SEEK_END));
-	__u32 size = 0;
+	uint32_t offset = (uint32_t)archtosword32(bdtfd->seek(0, SEEK_END));
+	uint32_t size = 0;
 	TreeKeyIdx *key = ((TreeKeyIdx *)&(getTreeKey()));
 
 	char userData[8];
@@ -144,7 +145,7 @@ void RawGenBook::setEntry(const char *inbuf, long len) {
 
 	bdtfd->write(inbuf, len);
 
-	size = (__u32)archtosword32(len);
+	size = (uint32_t)archtosword32(len);
 	memcpy(userData, &offset, 4);
 	memcpy(userData+4, &size, 4);
 	key->setUserData(userData, 8);
diff --git a/src/modules/lexdict/rawld/rawld.cpp b/src/modules/lexdict/rawld/rawld.cpp
index 2e758599..61579802 100644
--- a/src/modules/lexdict/rawld/rawld.cpp
+++ b/src/modules/lexdict/rawld/rawld.cpp
@@ -21,6 +21,8 @@
  *
  */
 
+#include <cstdint>
+
 #include <fcntl.h>
 
 #include <utilstr.h>
@@ -73,8 +75,8 @@ bool RawLD::isWritable() const {
 
 char RawLD::getEntry(long away) const
 {
-	__u32 start = 0;
-	__u16 size = 0;
+	uint32_t start = 0;
+	uint16_t size = 0;
 	char *idxbuf = 0;
 	char retval = 0;
 
@@ -195,8 +197,8 @@ long RawLD::getEntryCount() const {
 
 
 long RawLD::getEntryForKey(const char *key) const {
-	__u32 start, offset;
-	__u16 size;
+	uint32_t start, offset;
+	uint16_t size;
 	
 	char *buf = new char [ strlen(key) + 6 ];
 	strcpy(buf, key);
diff --git a/src/modules/lexdict/rawld4/rawld4.cpp b/src/modules/lexdict/rawld4/rawld4.cpp
index bfbe0cb5..8ce0ff35 100644
--- a/src/modules/lexdict/rawld4/rawld4.cpp
+++ b/src/modules/lexdict/rawld4/rawld4.cpp
@@ -21,6 +21,8 @@
  *
  */
 
+#include <cstdint>
+
 #include <fcntl.h>
 
 #include <filemgr.h>
@@ -73,8 +75,8 @@ bool RawLD4::isWritable() const {
 
 char RawLD4::getEntry(long away) const
 {
-	__u32 start  = 0;
-	__u32 size   = 0;
+	uint32_t start  = 0;
+	uint32_t size   = 0;
 	char *idxbuf = 0;
 	char retval  = 0;
 
@@ -193,8 +195,8 @@ long RawLD4::getEntryCount() const {
 
 
 long RawLD4::getEntryForKey(const char *key) const {
-	__u32 start, offset;
-	__u32 size;
+	uint32_t start, offset;
+	uint32_t size;
 
 	char *buf = new char [ strlen(key) + 6 ];
 	strcpy(buf, key);
diff --git a/src/modules/swmodule.cpp b/src/modules/swmodule.cpp
index e5589233..ce392846 100644
--- a/src/modules/swmodule.cpp
+++ b/src/modules/swmodule.cpp
@@ -23,6 +23,7 @@
  */
 
 
+#include <cstdint>
 #include <vector>
 
 #include <swlog.h>
@@ -556,7 +557,7 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
 			Xapian::MSetIterator i;
 			for (i = h.begin(); i != h.end(); ++i) {
 //				cout << "Document ID " << *i << "\t";
-				__u64 score = i.get_percent();
+				uint64_t score = i.get_percent();
 				Xapian::Document doc = i.get_document();
 				*resultKey = doc.get_data().c_str();
 #elif defined USELUCENE
@@ -564,7 +565,7 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
 				Document &doc = h->doc(i);
 				// set a temporary verse key to this module position
 				*resultKey = wcharToUTF8(doc.get(_T("key"))); //TODO Does a key always accept utf8?
-				__u64 score = (__u64)((__u32)(h->score(i)*100));
+				uint64_t score = (uint64_t)((uint32_t)(h->score(i)*100));
 #endif
 
 				// check to see if it sets ok (within our bounds) and if not, skip
diff --git a/tests/filtertest.cpp b/tests/filtertest.cpp
index 03c86954..f1e5de67 100644
--- a/tests/filtertest.cpp
+++ b/tests/filtertest.cpp
@@ -20,6 +20,7 @@
  *
  */
 
+#include <cstdint>
 #include <iostream>
 #include <swbuf.h>
 #include <filemgr.h>
@@ -72,7 +73,7 @@ int main(int argc, char **argv) {
 /*
 //	Example showing safe to cast to u16 stream
 		unsigned int size = lineBuffer.size() / 2;
-		__u16 *wcharBuf = (__u16 *)lineBuffer.getRawData();
+		uint16_t *wcharBuf = (uint16_t *)lineBuffer.getRawData();
 		for (unsigned int i = 0; i < size; ++i) {
 			std::wcout << (wchar_t)wcharBuf[i];	// must cast for correct output and because wchar_t is different size on linux we couldn't declare out wcharBuf a wchar_t *
 		}
diff --git a/tests/utf8norm.cpp b/tests/utf8norm.cpp
index 06143c43..1f2daf98 100644
--- a/tests/utf8norm.cpp
+++ b/tests/utf8norm.cpp
@@ -20,6 +20,7 @@
  *
  */
 
+#include <cstdint>
 #include <iostream>
 #include <utilstr.h>
 #include <swbuf.h>
@@ -67,7 +68,7 @@ int main(int argc, char **argv) {
 		}
 		const unsigned char *c = (const unsigned char *)filteredContents.getRawData();
 		// UTF-32 BOM
-		__u32 ch = 0xfeff;
+		uint32_t ch = 0xfeff;
 //		write(STDOUT_FILENO, &ch, 4);
 		while (c && *c) {
 			ch = getUniCharFromUTF8(&c);
-- 
2.20.1



More information about the sword-devel mailing list