1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-22 19:54:57 +08:00

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.
This commit is contained in:
Chet Helms 2023-12-22 13:14:36 -05:00
parent 69e0372cf0
commit e5331d09fc

View File

@ -3,6 +3,7 @@
/* Copyright 2012 William Woodall and John Harrison */ /* Copyright 2012 William Woodall and John Harrison */
#include <sstream> #include <sstream>
#include <algorithm>
#include "serial/impl/win.h" #include "serial/impl/win.h"
@ -366,7 +367,11 @@ Serial::SerialImpl::setPort (const string &port)
string string
Serial::SerialImpl::getPort () const 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 void