Skip to content

Commit 8d9be9b

Browse files
committed
Fix for MacOS unsupported function
1 parent 27ba3ea commit 8d9be9b

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/lib/Statement.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#include "SmartPtrs.h"
3838
#include "Exception.h"
3939
#include <charconv>
40+
#include <cerrno>
41+
#include <cstdlib>
4042
#include <limits>
4143
#include <memory>
4244
#include <optional>
@@ -1129,9 +1131,18 @@ namespace fbcpp
11291131
case DescriptorAdjustedType::DOUBLE:
11301132
{
11311133
double doubleValue;
1134+
#if defined(__APPLE__)
1135+
errno = 0;
1136+
std::string valueString{value};
1137+
char* parseEnd = nullptr;
1138+
doubleValue = std::strtod(valueString.c_str(), &parseEnd);
1139+
if (parseEnd != valueString.c_str() + valueString.size() || errno == ERANGE)
1140+
numericConverter.throwConversionErrorFromString(std::move(valueString));
1141+
#else
11321142
const auto convResult = std::from_chars(value.data(), value.data() + value.size(), doubleValue);
11331143
if (convResult.ec != std::errc{} || convResult.ptr != value.data() + value.size())
11341144
numericConverter.throwConversionErrorFromString(std::string{value});
1145+
#endif
11351146
setDouble(index, doubleValue);
11361147
return;
11371148
}

0 commit comments

Comments
 (0)