Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win .dll build support #264

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions include/serial/libserial_exports.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#if defined(_WIN32)
# if !defined(LIBSERIAL_DYNAMIC)
# 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

18 changes: 10 additions & 8 deletions include/serial/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
#include <sstream>
#include <exception>
#include <stdexcept>
#include <serial/v8stdint.h>
#include <stdint.h>

#include "libserial_exports.h"

#define THROW(exceptionClass, message) throw exceptionClass(__FILE__, \
__LINE__, (message) )
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -669,7 +671,7 @@ class Serial {

};

class SerialException : public std::exception
class LIBSERIAL_EXPORT_API SerialException : public std::exception
{
// Disable copy constructors
SerialException& operator=(const SerialException&);
Expand All @@ -687,7 +689,7 @@ class SerialException : public std::exception
}
};

class IOException : public std::exception
class LIBSERIAL_EXPORT_API IOException : public std::exception
{
// Disable copy constructors
IOException& operator=(const IOException&);
Expand Down Expand Up @@ -726,7 +728,7 @@ class IOException : public std::exception
}
};

class PortNotOpenedException : public std::exception
class LIBSERIAL_EXPORT_API PortNotOpenedException : public std::exception
{
// Disable copy constructors
const PortNotOpenedException& operator=(PortNotOpenedException);
Expand All @@ -747,7 +749,7 @@ class PortNotOpenedException : public std::exception
/*!
* 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;
Expand All @@ -767,7 +769,7 @@ struct PortInfo {
*
* \return vector of serial::PortInfo.
*/
std::vector<PortInfo>
LIBSERIAL_EXPORT_API std::vector<PortInfo>
list_ports();

} // namespace serial
Expand Down
57 changes: 0 additions & 57 deletions include/serial/v8stdint.h

This file was deleted.

Empty file modified src/impl/unix.cc
100755 → 100644
Empty file.
Empty file modified src/serial.cc
100755 → 100644
Empty file.