Просмотр исходного кода

Avoid constraints in header ordering

This change fixes a compilation problem in MinGW. As general rule,
each header must be as independent as possible.
Stéphane Raimbault 14 лет назад
Родитель
Сommit
50fa79da23
6 измененных файлов с 16 добавлено и 2 удалено
  1. 4 0
      src/modbus-private.h
  2. 5 2
      src/modbus-rtu-private.h
  3. 2 0
      src/modbus-rtu.h
  4. 1 0
      src/modbus-tcp.c
  5. 2 0
      src/modbus-tcp.h
  6. 2 0
      src/modbus.h

+ 4 - 0
src/modbus-private.h

@@ -18,6 +18,10 @@
 #ifndef _MODBUS_PRIVATE_H_
 #define _MODBUS_PRIVATE_H_
 
+#include <sys/time.h>
+#include <sys/types.h>
+#include <stdint.h>
+
 #include "modbus.h"
 
 MODBUS_BEGIN_DECLS

+ 5 - 2
src/modbus-rtu-private.h

@@ -18,6 +18,9 @@
 #ifndef _MODBUS_RTU_PRIVATE_H_
 #define _MODBUS_RTU_PRIVATE_H_
 
+#include <stdint.h>
+#include <termios.h>
+
 #define _MODBUS_RTU_HEADER_LENGTH      1
 #define _MODBUS_RTU_PRESET_REQ_LENGTH  6
 #define _MODBUS_RTU_PRESET_RSP_LENGTH  2
@@ -61,8 +64,8 @@ typedef struct _modbus_rtu {
     /* Parity: 'N', 'O', 'E' */
     char parity;
 #ifdef NATIVE_WIN32
-	struct win32_ser w_ser;
-	DCB old_dcb;
+    struct win32_ser w_ser;
+    DCB old_dcb;
 #else
     /* Save old termios settings */
     struct termios old_tios;

+ 2 - 0
src/modbus-rtu.h

@@ -18,6 +18,8 @@
 #ifndef _MODBUS_RTU_H_
 #define _MODBUS_RTU_H_
 
+#include "modbus.h"
+
 /* Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5
  * RS232 / RS485 ADU = 253 bytes + slave (1 byte) + CRC (2 bytes) = 256 bytes
  */

+ 1 - 0
src/modbus-tcp.c

@@ -25,6 +25,7 @@
 #include <unistd.h>
 
 #include <sys/types.h>
+
 #ifdef NATIVE_WIN32
 #include <ws2tcpip.h>
 #else

+ 2 - 0
src/modbus-tcp.h

@@ -18,6 +18,8 @@
 #ifndef _MODBUS_TCP_H_
 #define _MODBUS_TCP_H_
 
+#include "modbus.h"
+
 #define MODBUS_TCP_DEFAULT_PORT   502
 #define MODBUS_TCP_SLAVE         0xFF
 

+ 2 - 0
src/modbus.h

@@ -38,7 +38,9 @@
 #endif
 #include <stdint.h>
 #ifndef NATIVE_WIN32
+
 #include <termios.h>
+
 #if defined(OpenBSD) || (defined(__FreeBSD__) && __FreeBSD__ < 5)
 #include <netinet/in_systm.h>
 #endif