Commit 50fa79da237fe18bbdf28c1f8461ebd13336bda8

Authored by Stéphane Raimbault
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.
src/modbus-private.h
... ... @@ -18,6 +18,10 @@
18 18 #ifndef _MODBUS_PRIVATE_H_
19 19 #define _MODBUS_PRIVATE_H_
20 20  
  21 +#include <sys/time.h>
  22 +#include <sys/types.h>
  23 +#include <stdint.h>
  24 +
21 25 #include "modbus.h"
22 26  
23 27 MODBUS_BEGIN_DECLS
... ...
src/modbus-rtu-private.h
... ... @@ -18,6 +18,9 @@
18 18 #ifndef _MODBUS_RTU_PRIVATE_H_
19 19 #define _MODBUS_RTU_PRIVATE_H_
20 20  
  21 +#include <stdint.h>
  22 +#include <termios.h>
  23 +
21 24 #define _MODBUS_RTU_HEADER_LENGTH 1
22 25 #define _MODBUS_RTU_PRESET_REQ_LENGTH 6
23 26 #define _MODBUS_RTU_PRESET_RSP_LENGTH 2
... ... @@ -61,8 +64,8 @@ typedef struct _modbus_rtu {
61 64 /* Parity: 'N', 'O', 'E' */
62 65 char parity;
63 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 69 #else
67 70 /* Save old termios settings */
68 71 struct termios old_tios;
... ...
src/modbus-rtu.h
... ... @@ -18,6 +18,8 @@
18 18 #ifndef _MODBUS_RTU_H_
19 19 #define _MODBUS_RTU_H_
20 20  
  21 +#include "modbus.h"
  22 +
21 23 /* Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5
22 24 * RS232 / RS485 ADU = 253 bytes + slave (1 byte) + CRC (2 bytes) = 256 bytes
23 25 */
... ...
src/modbus-tcp.c
... ... @@ -25,6 +25,7 @@
25 25 #include <unistd.h>
26 26  
27 27 #include <sys/types.h>
  28 +
28 29 #ifdef NATIVE_WIN32
29 30 #include <ws2tcpip.h>
30 31 #else
... ...
src/modbus-tcp.h
... ... @@ -18,6 +18,8 @@
18 18 #ifndef _MODBUS_TCP_H_
19 19 #define _MODBUS_TCP_H_
20 20  
  21 +#include "modbus.h"
  22 +
21 23 #define MODBUS_TCP_DEFAULT_PORT 502
22 24 #define MODBUS_TCP_SLAVE 0xFF
23 25  
... ...
src/modbus.h
... ... @@ -38,7 +38,9 @@
38 38 #endif
39 39 #include <stdint.h>
40 40 #ifndef NATIVE_WIN32
  41 +
41 42 #include <termios.h>
  43 +
42 44 #if defined(OpenBSD) || (defined(__FreeBSD__) && __FreeBSD__ < 5)
43 45 #include <netinet/in_systm.h>
44 46 #endif
... ...