summaryrefslogtreecommitdiff
path: root/zen/legacy_compiler.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <shieldwed@outlook.com>2019-10-28 23:21:40 +0000
committerDaniel Wilhelm <shieldwed@outlook.com>2019-10-28 23:21:40 +0000
commit8d6d4e48a61fd974c3fb2a85254f9bedd796a2b7 (patch)
tree65292208a81994782e1c16dd84dfcdcc221d0cd7 /zen/legacy_compiler.cpp
parentMerge branch '10.16' into 'master' (diff)
parentadd upstream 10.17 (diff)
downloadFreeFileSync-8d6d4e48a61fd974c3fb2a85254f9bedd796a2b7.tar.gz
FreeFileSync-8d6d4e48a61fd974c3fb2a85254f9bedd796a2b7.tar.bz2
FreeFileSync-8d6d4e48a61fd974c3fb2a85254f9bedd796a2b7.zip
Merge branch '10.17' into 'master'10.17
10.17 See merge request opensource-tracking/FreeFileSync!14
Diffstat (limited to 'zen/legacy_compiler.cpp')
-rw-r--r--zen/legacy_compiler.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/zen/legacy_compiler.cpp b/zen/legacy_compiler.cpp
new file mode 100644
index 00000000..3e3b7ba7
--- /dev/null
+++ b/zen/legacy_compiler.cpp
@@ -0,0 +1,32 @@
+// *****************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: https://www.gnu.org/licenses/gpl-3.0 *
+// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved *
+// *****************************************************************************
+
+#include "legacy_compiler.h"
+#include <charconv>
+//1. including this one in string_tools.h blows up VC++:
+// "An internal error has occurred in the compiler. (compiler file 'd:\agent\_work\1\s\src\vctools\Compiler\Utc\src\p2\p2symtab.c', line 2618)"
+//2. using inside PCH: "fatal error C1076: compiler limit: internal heap limit reached"
+
+
+#if __cpp_lib_to_chars
+ #error get rid of workarounds
+#endif
+
+double zen::from_chars(const char* first, const char* last)
+{
+ return std::strtod(std::string(first, last).c_str(), nullptr);
+}
+
+
+const char* zen::to_chars(char* first, char* last, double num)
+{
+ const size_t bufSize = last - first;
+ const int charsWritten = std::snprintf(first, bufSize, "%g", num);
+ //C99: returns number of chars written if successful, < 0 or >= bufferSize on failure
+
+ return 0 <= charsWritten && charsWritten < static_cast<int>(bufSize) ?
+ first + charsWritten : first;
+}
bgstack15