From b37c58e0bfd857a98b3fcabcf9c073040204a4e5 Mon Sep 17 00:00:00 2001 From: skarg Date: Tue, 21 Aug 2007 23:03:01 +0000 Subject: [PATCH] Updated stdint.h and stdbool.h which are used with compilers that are pre-C99 standard (i.e. borland). This also cleaned up warnings when built with codeblocks using MinGW. --- bacnet-stack/bip.c | 2 +- bacnet-stack/ports/win32/bip-init.c | 1 - bacnet-stack/ports/win32/stdbool.h | 23 ++++++----------------- bacnet-stack/ports/win32/stdint.h | 20 ++++++++++++++++---- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/bacnet-stack/bip.c b/bacnet-stack/bip.c index 0968b27e..a192c4ec 100644 --- a/bacnet-stack/bip.c +++ b/bacnet-stack/bip.c @@ -135,7 +135,7 @@ int bip_send_pdu(BACNET_ADDRESS * dest, /* destination address */ } else if (dest->mac_len == 6) { /* valid unicast */ (void) decode_unsigned32(&dest->mac[0], - &(bip_dest.sin_addr.s_addr)); + (uint32_t *)&(bip_dest.sin_addr.s_addr)); (void) decode_unsigned16(&dest->mac[4], &(bip_dest.sin_port)); memset(&(bip_dest.sin_zero), '\0', 8); mtu[1] = BVLC_ORIGINAL_UNICAST_NPDU; diff --git a/bacnet-stack/ports/win32/bip-init.c b/bacnet-stack/ports/win32/bip-init.c index 411e26c1..13c476d0 100644 --- a/bacnet-stack/ports/win32/bip-init.c +++ b/bacnet-stack/ports/win32/bip-init.c @@ -71,7 +71,6 @@ static void set_broadcast_address(uint32_t net_address) bip_set_broadcast_addr(INADDR_BROADCAST); #else long broadcast_address = 0; - long mask = 0; if (IN_CLASSA(ntohl(net_address))) broadcast_address = diff --git a/bacnet-stack/ports/win32/stdbool.h b/bacnet-stack/ports/win32/stdbool.h index 4c05de20..29c310c3 100644 --- a/bacnet-stack/ports/win32/stdbool.h +++ b/bacnet-stack/ports/win32/stdbool.h @@ -1,28 +1,17 @@ -#ifndef STDBOOL_H -#define STDBOOL_H +#ifndef _STDBOOL_H +#define _STDBOOL_H /* C99 Boolean types for compilers without C99 support */ +/* http://www.opengroup.org/onlinepubs/009695399/basedefs/stdbool.h.html */ -#ifndef __cplusplus -typedef int _Bool; -#ifndef bool +#if !defined(__cplusplus) + +/*typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;*/ #define bool _Bool -#endif -#ifndef true #define true 1 -#endif -#ifndef false #define false 0 -#endif #define __bool_true_false_are_defined 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 #endif #endif diff --git a/bacnet-stack/ports/win32/stdint.h b/bacnet-stack/ports/win32/stdint.h index 3bd54ae8..93f1a85b 100644 --- a/bacnet-stack/ports/win32/stdint.h +++ b/bacnet-stack/ports/win32/stdint.h @@ -1,8 +1,8 @@ /* Defines the standard integer types that are used in code */ /* for the x86 processor and Borland Compiler */ -#ifndef STDINT_H -#define STDINT_H +#ifndef _STDINT_H +#define _STDINT_H #include @@ -11,9 +11,21 @@ typedef signed char int8_t; /* 1 byte -127 to 127 */ typedef unsigned short uint16_t; /* 2 bytes 0 to 65535 */ typedef signed short int16_t; /* 2 bytes -32767 to 32767 */ /*typedef unsigned short long uint24_t; // 3 bytes 0 to 16777215 */ -typedef unsigned long uint32_t; /* 4 bytes 0 to 4294967295 */ -typedef signed long int32_t; /* 4 bytes -2147483647 to 2147483647 */ +typedef unsigned uint32_t; /* 4 bytes 0 to 4294967295 */ +typedef int int32_t; /* 4 bytes -2147483647 to 2147483647 */ /* typedef signed long long int64_t; */ /* typedef unsigned long long uint64_t; */ +#define INT8_MIN (-128) +#define INT16_MIN (-32768) +#define INT32_MIN (-2147483647 - 1) + +#define INT8_MAX 127 +#define INT16_MAX 32767 +#define INT32_MAX 2147483647 + +#define UINT8_MAX 0xff /* 255U */ +#define UINT16_MAX 0xffff /* 65535U */ +#define UINT32_MAX 0xffffffff /* 4294967295U */ + #endif /* STDINT_H */