mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-22 19:54:57 +08:00
Fix compiler warnings on Windows
This commit is contained in:
parent
3292f2b682
commit
e11abb04f2
@ -55,7 +55,11 @@ int run(int argc, char **argv)
|
||||
|
||||
// Argument 2 is the baudrate
|
||||
unsigned long baud = 0;
|
||||
#ifdef WIN32
|
||||
sscanf_s(argv[2], "%lu", &baud);
|
||||
#else
|
||||
sscanf(argv[2], "%lu", &baud);
|
||||
#endif
|
||||
|
||||
// port, baudrate, timeout in milliseconds
|
||||
serial::Serial my_serial(port, baud, serial::Timeout::simpleTimeout(1000));
|
||||
|
||||
@ -599,8 +599,7 @@ public:
|
||||
private:
|
||||
// Disable copy constructors
|
||||
Serial(const Serial&);
|
||||
void operator=(const Serial&);
|
||||
const Serial& operator=(Serial);
|
||||
Serial& operator=(const Serial&);
|
||||
|
||||
std::string read_cache_; //!< Cache for doing reads in chunks.
|
||||
|
||||
@ -624,8 +623,7 @@ private:
|
||||
class SerialException : public std::exception
|
||||
{
|
||||
// Disable copy constructors
|
||||
void operator=(const SerialException&);
|
||||
const SerialException& operator=(SerialException);
|
||||
SerialException& operator=(const SerialException&);
|
||||
std::string e_what_;
|
||||
public:
|
||||
SerialException (const char *description) {
|
||||
@ -645,8 +643,7 @@ public:
|
||||
class IOException : public std::exception
|
||||
{
|
||||
// Disable copy constructors
|
||||
void operator=(const IOException&);
|
||||
const IOException& operator=(IOException);
|
||||
IOException& operator=(const IOException&);
|
||||
std::string file_;
|
||||
int line_;
|
||||
std::string e_what_;
|
||||
@ -655,7 +652,13 @@ public:
|
||||
explicit IOException (std::string file, int line, int errnum)
|
||||
: file_(file), line_(line), errno_(errnum) {
|
||||
std::stringstream ss;
|
||||
ss << "IO Exception (" << errno_ << "): " << strerror (errnum);
|
||||
char error_str [1024];
|
||||
#ifdef WIN32
|
||||
strerror_s(error_str, 1024, errnum);
|
||||
#else
|
||||
error_str = strerror(errnum);
|
||||
#endif
|
||||
ss << "IO Exception (" << errno_ << "): " << error_str;
|
||||
ss << ", file " << file_ << ", line " << line_ << ".";
|
||||
e_what_ = ss.str();
|
||||
}
|
||||
@ -681,7 +684,6 @@ public:
|
||||
class PortNotOpenedException : public std::exception
|
||||
{
|
||||
// Disable copy constructors
|
||||
void operator=(const PortNotOpenedException&);
|
||||
const PortNotOpenedException& operator=(PortNotOpenedException);
|
||||
std::string e_what_;
|
||||
public:
|
||||
|
||||
@ -49,7 +49,7 @@ Serial::SerialImpl::open ()
|
||||
}
|
||||
|
||||
LPCWSTR lp_port = port_.c_str();
|
||||
fd_ = CreateFile(lp_port,
|
||||
fd_ = CreateFileW(lp_port,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
0,
|
||||
@ -508,7 +508,7 @@ Serial::SerialImpl::getCTS ()
|
||||
THROW (IOException, "Error getting the status of the CTS line.");
|
||||
}
|
||||
|
||||
return (bool) (MS_CTS_ON & dwModemStatus);
|
||||
return (MS_CTS_ON & dwModemStatus) != 0;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -522,7 +522,7 @@ Serial::SerialImpl::getDSR ()
|
||||
THROW (IOException, "Error getting the status of the DSR line.");
|
||||
}
|
||||
|
||||
return (bool) (MS_DSR_ON & dwModemStatus);
|
||||
return (MS_DSR_ON & dwModemStatus) != 0;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -536,7 +536,7 @@ Serial::SerialImpl::getRI()
|
||||
THROW (IOException, "Error getting the status of the RI line.");
|
||||
}
|
||||
|
||||
return (bool) (MS_RING_ON & dwModemStatus);
|
||||
return (MS_RING_ON & dwModemStatus) != 0;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -551,7 +551,7 @@ Serial::SerialImpl::getCD()
|
||||
THROW (IOException, "Error getting the status of the CD line.");
|
||||
}
|
||||
|
||||
return (bool) (MS_RLSD_ON & dwModemStatus);
|
||||
return (MS_RLSD_ON & dwModemStatus) != 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@ -37,7 +37,6 @@ public:
|
||||
private:
|
||||
// Disable copy constructors
|
||||
ScopedReadLock(const ScopedReadLock&);
|
||||
void operator=(const ScopedReadLock&);
|
||||
const ScopedReadLock& operator=(ScopedReadLock);
|
||||
|
||||
SerialImpl *pimpl_;
|
||||
@ -54,7 +53,6 @@ public:
|
||||
private:
|
||||
// Disable copy constructors
|
||||
ScopedWriteLock(const ScopedWriteLock&);
|
||||
void operator=(const ScopedWriteLock&);
|
||||
const ScopedWriteLock& operator=(ScopedWriteLock);
|
||||
SerialImpl *pimpl_;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user