Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
authoretisserant
Mon, 17 Sep 2007 17:56:29 +0200
changeset 59 37ba6f9e51e2
parent 58 273d6d5cec9d
child 60 6f489cf54897
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
lib/iec_std_lib.h
lib/iec_types.h
--- a/lib/iec_std_lib.h	Mon Sep 17 17:47:10 2007 +0200
+++ b/lib/iec_std_lib.h	Mon Sep 17 17:56:29 2007 +0200
@@ -44,59 +44,47 @@
 #define DBG_TYPE(TYPENAME, name)
 #endif
 
-/*****************/
-/*  Types defs   */
-/*****************/
-
-typedef uint8_t  BOOL;
+/*********************/
+/*  IEC Types defs   */
+/*********************/
+
+/* Include non windows.h clashing typedefs */
+#include "iec_types.h"
+
+/* Those typdefs clash with windows.h */
+/* i.e. this file cannot be included aside windows.h */
+typedef IEC_BOOL  BOOL;
 
 #define TRUE 1
 #define FALSE 0
 
-typedef int8_t    SINT;
-typedef int16_t   INT;
-typedef int32_t   DINT;
-typedef int64_t   LINT;
-
-typedef uint8_t    USINT;
-typedef uint16_t   UINT;
-typedef uint32_t   UDINT;
-typedef uint64_t   ULINT;
-
-typedef uint8_t    BYTE;
-typedef uint16_t   WORD;
-typedef uint32_t   DWORD;
-typedef uint64_t   LWORD;
-
-typedef float    REAL;
-typedef double   LREAL;
-
-
-#if !defined __timespec_defined
-# define __timespec_defined     1
-
-struct timespec
-  {
-    long int tv_sec;            /* Seconds.  */
-    long int tv_nsec;           /* Nanoseconds.  */
-  };
-
-#endif
-
-typedef struct timespec TIME;
-typedef struct timespec DATE;
-typedef struct timespec DT;
-typedef struct timespec TOD;
+typedef IEC_SINT    SINT;
+typedef IEC_INT   INT;
+typedef IEC_DINT   DINT;
+typedef IEC_LINT   LINT;
+
+typedef IEC_USINT    USINT;
+typedef IEC_UINT   UINT;
+typedef IEC_UDINT   UDINT;
+typedef IEC_ULINT   ULINT;
+
+typedef IEC_BYTE    BYTE;
+typedef IEC_WORD   WORD;
+typedef IEC_DWORD   DWORD;
+typedef IEC_LWORD   LWORD;
+
+typedef IEC_REAL    REAL;
+typedef IEC_LREAL   LREAL;
+
+typedef IEC_TIME TIME;
+typedef IEC_DATE DATE;
+typedef IEC_DT DT;
+typedef IEC_TOD TOD;
 
 #define __TIME_CMP(t1, t2) (t2.tv_sec == t1.tv_sec ? t2.tv_nsec - t1.tv_nsec : t1.tv_sec - t2.tv_sec) 
 extern TIME __CURRENT_TIME;
 
-#define STR_MAX_LEN 40
-typedef int8_t __strlen_t;
-typedef struct {
-    __strlen_t len;
-    uint8_t body[STR_MAX_LEN];
-} STRING;
+typedef IEC_STRING STRING;
 
 #define __STR_CMP(str1, str2) memcmp((char*)&str1.body,(char*)&str2.body, str1.len < str2.len ? str1.len : str2.len)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/iec_types.h	Mon Sep 17 17:56:29 2007 +0200
@@ -0,0 +1,53 @@
+#include <limits.h>
+#include <float.h>
+#include <time.h>
+#include <stdint.h>
+
+/*********************/
+/*  IEC Types defs   */
+/*********************/
+
+typedef uint8_t  IEC_BOOL;
+
+typedef int8_t    IEC_SINT;
+typedef int16_t   IEC_INT;
+typedef int32_t   IEC_DINT;
+typedef int64_t   IEC_LINT;
+
+typedef uint8_t    IEC_USINT;
+typedef uint16_t   IEC_UINT;
+typedef uint32_t   IEC_UDINT;
+typedef uint64_t   IEC_ULINT;
+
+typedef uint8_t    IEC_BYTE;
+typedef uint16_t   IEC_WORD;
+typedef uint32_t   IEC_DWORD;
+typedef uint64_t   IEC_LWORD;
+
+typedef float    IEC_REAL;
+typedef double   IEC_LREAL;
+
+
+#if !defined __timespec_defined
+# define __timespec_defined     1
+
+struct timespec
+  {
+    long int tv_sec;            /* Seconds.  */
+    long int tv_nsec;           /* Nanoseconds.  */
+  };
+
+#endif
+
+typedef struct timespec IEC_TIME;
+typedef struct timespec IEC_DATE;
+typedef struct timespec IEC_DT;
+typedef struct timespec IEC_TOD;
+
+#define STR_MAX_LEN 40
+typedef int8_t __strlen_t;
+typedef struct {
+    __strlen_t len;
+    uint8_t body[STR_MAX_LEN];
+} IEC_STRING;
+