mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-22 03:34:53 +08:00
Win .dll build support
This commit is contained in:
parent
55d1bf8f25
commit
e2b713e8d6
17
include/serial/libserial_exports.h
Executable file
17
include/serial/libserial_exports.h
Executable file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
# if defined(LIBSERIAL_STATIC)
|
||||
# define LIBSERIAL_EXPORT_API
|
||||
# else
|
||||
# if defined(LIBSERIAL_EXPORTS)
|
||||
# define LIBSERIAL_EXPORT_API __declspec(dllexport)
|
||||
# else
|
||||
# define LIBSERIAL_EXPORT_API __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# define LIBSERIAL_EXPORT_API
|
||||
#endif
|
||||
|
||||
@ -45,6 +45,8 @@
|
||||
#include <stdexcept>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libserial_exports.h"
|
||||
|
||||
#define THROW(exceptionClass, message) throw exceptionClass(__FILE__, \
|
||||
__LINE__, (message) )
|
||||
|
||||
@ -95,7 +97,7 @@ typedef enum {
|
||||
*
|
||||
* In order to disable the interbyte timeout, set it to Timeout::max().
|
||||
*/
|
||||
struct Timeout {
|
||||
struct LIBSERIAL_EXPORT_API Timeout {
|
||||
#ifdef max
|
||||
# undef max
|
||||
#endif
|
||||
@ -144,7 +146,7 @@ struct Timeout {
|
||||
/*!
|
||||
* Class that provides a portable serial port interface.
|
||||
*/
|
||||
class Serial {
|
||||
class LIBSERIAL_EXPORT_API Serial {
|
||||
public:
|
||||
/*!
|
||||
* Creates a Serial object and opens the port if a port is specified,
|
||||
@ -669,7 +671,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class SerialException : public std::exception
|
||||
class LIBSERIAL_EXPORT_API SerialException : public std::exception
|
||||
{
|
||||
// Disable copy constructors
|
||||
SerialException& operator=(const SerialException&);
|
||||
@ -687,7 +689,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class IOException : public std::exception
|
||||
class LIBSERIAL_EXPORT_API IOException : public std::exception
|
||||
{
|
||||
// Disable copy constructors
|
||||
IOException& operator=(const IOException&);
|
||||
@ -726,7 +728,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class PortNotOpenedException : public std::exception
|
||||
class LIBSERIAL_EXPORT_API PortNotOpenedException : public std::exception
|
||||
{
|
||||
// Disable copy constructors
|
||||
const PortNotOpenedException& operator=(PortNotOpenedException);
|
||||
@ -747,7 +749,7 @@ public:
|
||||
/*!
|
||||
* Structure that describes a serial device.
|
||||
*/
|
||||
struct PortInfo {
|
||||
struct LIBSERIAL_EXPORT_API PortInfo {
|
||||
|
||||
/*! Address of the serial port (this can be passed to the constructor of Serial). */
|
||||
std::string port;
|
||||
@ -767,7 +769,7 @@ struct PortInfo {
|
||||
*
|
||||
* \return vector of serial::PortInfo.
|
||||
*/
|
||||
std::vector<PortInfo>
|
||||
LIBSERIAL_EXPORT_API std::vector<PortInfo>
|
||||
list_ports();
|
||||
|
||||
} // namespace serial
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user