diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 874d611e27540a90fee692de4fa5c1ee5b70cf37..10572ebe53723047aae2e5683c487518596c9cb4 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -3394,9 +3394,17 @@ PUGI__NS_BEGIN
 		int base = get_integer_base(value);
 
 	#ifdef PUGIXML_WCHAR_MODE
-		return wcstoll(value, 0, base);
+		#ifdef PUGI__MSVC_CRT_VERSION
+			return _wcstoi64(value, 0, base);
+		#else
+			return wcstoll(value, 0, base);
+		#endif
 	#else
-		return strtoll(value, 0, base);
+		#ifdef PUGI__MSVC_CRT_VERSION
+			return _strtoi64(value, 0, base);
+		#else
+			return strtoll(value, 0, base);
+		#endif
 	#endif
 	}
 
@@ -3407,9 +3415,17 @@ PUGI__NS_BEGIN
 		int base = get_integer_base(value);
 
 	#ifdef PUGIXML_WCHAR_MODE
-		return wcstoull(value, 0, base);
+		#ifdef PUGI__MSVC_CRT_VERSION
+			return _wcstoui64(value, 0, base);
+		#else
+			return wcstoull(value, 0, base);
+		#endif
 	#else
-		return strtoull(value, 0, base);
+		#ifdef PUGI__MSVC_CRT_VERSION
+			return _strtoui64(value, 0, base);
+		#else
+			return strtoull(value, 0, base);
+		#endif
 	#endif
 	}
 #endif
diff --git a/src/pugixml.hpp b/src/pugixml.hpp
index a988b90d78607984f145f5436d2393aa30acd1cf..bf8da039e2f63e3f1c7e266fb2ef7c8ea9354250 100644
--- a/src/pugixml.hpp
+++ b/src/pugixml.hpp
@@ -63,6 +63,15 @@
 #	define PUGIXML_FUNCTION PUGIXML_API
 #endif
 
+// If the platform is known to have long long support, enable long long functions
+#ifndef PUGIXML_HAS_LONG_LONG
+#	if defined(__cplusplus) && __cplusplus >= 201103
+#		define PUGIXML_HAS_LONG_LONG
+#	elif defined(_MSC_VER) && _MSC_VER >= 1400
+#		define PUGIXML_HAS_LONG_LONG
+#	endif
+#endif
+
 // Character interface macros
 #ifdef PUGIXML_WCHAR_MODE
 #	define PUGIXML_TEXT(t) L ## t