summaryrefslogtreecommitdiff
path: root/zen/legacy_compiler.cpp
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2021-05-10 12:09:24 +0000
committerB. Stack <bgstack15@gmail.com>2021-05-10 12:09:24 +0000
commit692fd264ae30b5b844f748626262e79bc3d5a7e2 (patch)
tree9261c60b81eb28e068f0f2f44fd8e60214462b2a /zen/legacy_compiler.cpp
parentMerge branch '11.9' into 'master' (diff)
parentadd upstream 11.10 (diff)
downloadFreeFileSync-692fd264ae30b5b844f748626262e79bc3d5a7e2.tar.gz
FreeFileSync-692fd264ae30b5b844f748626262e79bc3d5a7e2.tar.bz2
FreeFileSync-692fd264ae30b5b844f748626262e79bc3d5a7e2.zip
Merge branch '11.10' into 'master'11.10
add upstream 11.10 See merge request opensource-tracking/FreeFileSync!33
Diffstat (limited to 'zen/legacy_compiler.cpp')
-rw-r--r--zen/legacy_compiler.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/zen/legacy_compiler.cpp b/zen/legacy_compiler.cpp
index 81efb4dd..6c5489d5 100644
--- a/zen/legacy_compiler.cpp
+++ b/zen/legacy_compiler.cpp
@@ -5,22 +5,24 @@
// *****************************************************************************
#include "legacy_compiler.h"
-#ifdef __cpp_lib_to_chars
- #error get rid of workarounds
-#endif
+#include <charconv>
+/* 1. including <charconv> in header file blows up VC++:
+ - string_tools.h: "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)"
+ - PCH: "fatal error C1076: compiler limit: internal heap limit reached"
+ => include in separate compilation unit
+ 2. Disable "C/C++ -> Code Generation -> Smaller Type Check" (and PCH usage!), at least for this compilation unit: https://github.com/microsoft/STL/pull/171 */
double zen::fromChars(const char* first, const char* last)
{
- return std::strtod(std::string(first, last).c_str(), nullptr);
+ double num = 0;
+ [[maybe_unused]] const std::from_chars_result rv = std::from_chars(first, last, num);
+ return num;
}
const char* zen::toChars(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;
+ const std::to_chars_result rv = std::to_chars(first, last, num);
+ return rv.ec == std::errc{} ? rv.ptr : first;
}
+
bgstack15