diff --git a/include/serial/libserial_exports.h b/include/serial/libserial_exports.h new file mode 100755 index 0000000..994c35b --- /dev/null +++ b/include/serial/libserial_exports.h @@ -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 + diff --git a/include/serial/serial.h b/include/serial/serial.h index afa4ce1..9e22530 100755 --- a/include/serial/serial.h +++ b/include/serial/serial.h @@ -45,6 +45,8 @@ #include #include +#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 +LIBSERIAL_EXPORT_API std::vector list_ports(); } // namespace serial