Commit 50fa79da237fe18bbdf28c1f8461ebd13336bda8
1 parent
0186a11c
Avoid constraints in header ordering
This change fixes a compilation problem in MinGW. As general rule, each header must be as independent as possible.
Showing
6 changed files
with
16 additions
and
2 deletions
src/modbus-private.h
| @@ -18,6 +18,10 @@ | @@ -18,6 +18,10 @@ | ||
| 18 | #ifndef _MODBUS_PRIVATE_H_ | 18 | #ifndef _MODBUS_PRIVATE_H_ |
| 19 | #define _MODBUS_PRIVATE_H_ | 19 | #define _MODBUS_PRIVATE_H_ |
| 20 | 20 | ||
| 21 | +#include <sys/time.h> | ||
| 22 | +#include <sys/types.h> | ||
| 23 | +#include <stdint.h> | ||
| 24 | + | ||
| 21 | #include "modbus.h" | 25 | #include "modbus.h" |
| 22 | 26 | ||
| 23 | MODBUS_BEGIN_DECLS | 27 | MODBUS_BEGIN_DECLS |
src/modbus-rtu-private.h
| @@ -18,6 +18,9 @@ | @@ -18,6 +18,9 @@ | ||
| 18 | #ifndef _MODBUS_RTU_PRIVATE_H_ | 18 | #ifndef _MODBUS_RTU_PRIVATE_H_ |
| 19 | #define _MODBUS_RTU_PRIVATE_H_ | 19 | #define _MODBUS_RTU_PRIVATE_H_ |
| 20 | 20 | ||
| 21 | +#include <stdint.h> | ||
| 22 | +#include <termios.h> | ||
| 23 | + | ||
| 21 | #define _MODBUS_RTU_HEADER_LENGTH 1 | 24 | #define _MODBUS_RTU_HEADER_LENGTH 1 |
| 22 | #define _MODBUS_RTU_PRESET_REQ_LENGTH 6 | 25 | #define _MODBUS_RTU_PRESET_REQ_LENGTH 6 |
| 23 | #define _MODBUS_RTU_PRESET_RSP_LENGTH 2 | 26 | #define _MODBUS_RTU_PRESET_RSP_LENGTH 2 |
| @@ -61,8 +64,8 @@ typedef struct _modbus_rtu { | @@ -61,8 +64,8 @@ typedef struct _modbus_rtu { | ||
| 61 | /* Parity: 'N', 'O', 'E' */ | 64 | /* Parity: 'N', 'O', 'E' */ |
| 62 | char parity; | 65 | char parity; |
| 63 | #ifdef NATIVE_WIN32 | 66 | #ifdef NATIVE_WIN32 |
| 64 | - struct win32_ser w_ser; | ||
| 65 | - DCB old_dcb; | 67 | + struct win32_ser w_ser; |
| 68 | + DCB old_dcb; | ||
| 66 | #else | 69 | #else |
| 67 | /* Save old termios settings */ | 70 | /* Save old termios settings */ |
| 68 | struct termios old_tios; | 71 | struct termios old_tios; |
src/modbus-rtu.h
| @@ -18,6 +18,8 @@ | @@ -18,6 +18,8 @@ | ||
| 18 | #ifndef _MODBUS_RTU_H_ | 18 | #ifndef _MODBUS_RTU_H_ |
| 19 | #define _MODBUS_RTU_H_ | 19 | #define _MODBUS_RTU_H_ |
| 20 | 20 | ||
| 21 | +#include "modbus.h" | ||
| 22 | + | ||
| 21 | /* Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5 | 23 | /* Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5 |
| 22 | * RS232 / RS485 ADU = 253 bytes + slave (1 byte) + CRC (2 bytes) = 256 bytes | 24 | * RS232 / RS485 ADU = 253 bytes + slave (1 byte) + CRC (2 bytes) = 256 bytes |
| 23 | */ | 25 | */ |
src/modbus-tcp.c
src/modbus-tcp.h
| @@ -18,6 +18,8 @@ | @@ -18,6 +18,8 @@ | ||
| 18 | #ifndef _MODBUS_TCP_H_ | 18 | #ifndef _MODBUS_TCP_H_ |
| 19 | #define _MODBUS_TCP_H_ | 19 | #define _MODBUS_TCP_H_ |
| 20 | 20 | ||
| 21 | +#include "modbus.h" | ||
| 22 | + | ||
| 21 | #define MODBUS_TCP_DEFAULT_PORT 502 | 23 | #define MODBUS_TCP_DEFAULT_PORT 502 |
| 22 | #define MODBUS_TCP_SLAVE 0xFF | 24 | #define MODBUS_TCP_SLAVE 0xFF |
| 23 | 25 |
src/modbus.h
| @@ -38,7 +38,9 @@ | @@ -38,7 +38,9 @@ | ||
| 38 | #endif | 38 | #endif |
| 39 | #include <stdint.h> | 39 | #include <stdint.h> |
| 40 | #ifndef NATIVE_WIN32 | 40 | #ifndef NATIVE_WIN32 |
| 41 | + | ||
| 41 | #include <termios.h> | 42 | #include <termios.h> |
| 43 | + | ||
| 42 | #if defined(OpenBSD) || (defined(__FreeBSD__) && __FreeBSD__ < 5) | 44 | #if defined(OpenBSD) || (defined(__FreeBSD__) && __FreeBSD__ < 5) |
| 43 | #include <netinet/in_systm.h> | 45 | #include <netinet/in_systm.h> |
| 44 | #endif | 46 | #endif |