From e5331d09fcd88d3c05bfe4cbc85701372672dd40 Mon Sep 17 00:00:00 2001 From: Chet Helms Date: Fri, 22 Dec 2023 13:14:36 -0500 Subject: [PATCH] Fixing comiler warning in win.cc The converstion from a wstring to std::string gave a warning C4244: 'argument': conversion from 'const wchar_t' to 'const _Elem', possible loss of data. --- src/impl/win.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/impl/win.cc b/src/impl/win.cc index 889e06f..1db2d4b 100644 --- a/src/impl/win.cc +++ b/src/impl/win.cc @@ -3,6 +3,7 @@ /* Copyright 2012 William Woodall and John Harrison */ #include +#include #include "serial/impl/win.h" @@ -366,7 +367,11 @@ Serial::SerialImpl::setPort (const string &port) string Serial::SerialImpl::getPort () const { - return string(port_.begin(), port_.end()); + string str(port_.length(), 0); + std::transform(port_.begin(), port_.end(), str.begin(), [] (wchar_t c) { + return (char)c; + }); + return str; } void