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

Fixes Windows MSVC build

Signed-off-by: Martin Melik Merkumians <melik-merkumians@acin.tuwien.ac.at>
Martin Melik Merkumians 7 лет назад
Родитель
Сommit
9bd461a72f

+ 1 - 0
source/src/cip/cipepath.c

@@ -12,6 +12,7 @@
 #include "endianconv.h"
 #include "cipelectronickey.h"
 #include "trace.h"
+#include <assert.h>
 
 const unsigned int kPortSegmentExtendedPort = 15; /**< Reserved port segment port value, indicating the use of the extended port field */
 

+ 1 - 1
source/src/ports/POSIX/sample_application/opener_user_conf.h

@@ -110,7 +110,7 @@ static const MilliSeconds kOpenerTimerTickInMilliSeconds = 10;
                 __LINE__); \
       while(1) {  } \
     } \
-  } while(0)
+  } while(0);
 
 /* else use standard assert() */
 //#include <assert.h>

+ 8 - 13
source/src/ports/WIN32/sample_application/opener_user_conf.h

@@ -27,6 +27,8 @@ typedef unsigned short in_port_t;
 /** @brief Identity configuration of the device */
 #include "devicedata.h"
 
+#include "typedefs.h"
+
 /** @brief Define the number of objects that may be used in connections
  *
  *  This number needs only to consider additional objects. Connections to
@@ -84,16 +86,6 @@ typedef unsigned short in_port_t;
  */
 static const int kOpenerTimerTickInMilliSeconds = 10;
 
-/** @brief Define if RUN IDLE data is sent with consumed data
- */
-static const int kOpenerConsumedDataHasRunIdleHeader = 1;
-
-/** @brief Define if RUN IDLE data is to be sent with produced data
- *
- * Per default we don't send run idle headers with produced data
- */
-static const int kOpenerProducedDataHasRunIdleHeader = 0;
-
 #ifdef OPENER_WITH_TRACES
 /* If we have tracing enabled provide print tracing macro */
 #include <stdio.h>
@@ -105,6 +97,7 @@ static const int kOpenerProducedDataHasRunIdleHeader = 0;
 /** @brief A specialized assertion command that will log the assertion and block
  *  further execution in an while(1) loop.
  */
+#ifdef IDLING_ASSERT
 #define OPENER_ASSERT(assertion) \
   do { \
     if( !(assertion) ) { \
@@ -114,8 +107,10 @@ static const int kOpenerProducedDataHasRunIdleHeader = 0;
                 __LINE__); \
       while(1) {;} \
     } \
-  } while(0)
-
+  } while(0);
+#else
+#define OPENER_ASSERT(assertion) assert(assertion);
+#endif
 /* else use standard assert() */
 //#include <assert.h>
 //#include <stdio.h>
@@ -123,7 +118,7 @@ static const int kOpenerProducedDataHasRunIdleHeader = 0;
 #else
 
 /* for release builds execute the assertion, but don't test it */
-#define OPENER_ASSERT(assertion) (assertion)
+#define OPENER_ASSERT(assertion) (assertion);
 
 /* the above may result in "statement with no effect" warnings.
  *  If you do not use assert()s to run functions, the an empty

+ 1 - 1
source/src/ports/generic_networkhandler.c

@@ -564,7 +564,7 @@ EipStatus SendUdpData(struct sockaddr_in *address,
     .checksum = 0
   };
 
-  char complete_message[data_length + kUpdHeaderLength];
+  char complete_message[PC_OPENER_ETHERNET_BUFFER_SIZE];
   memcpy(complete_message + kUpdHeaderLength, data, data_length);
   UDPHeaderGenerate(&header, (char *)complete_message);
   UDPHeaderSetChecksum(&header,

+ 4 - 0
source/src/ports/udp_protocol.c

@@ -6,6 +6,10 @@
 
 #include "udp_protocol.h"
 
+#ifdef WIN32
+#include <winsock.h>
+#endif
+
 void UDPHeaderSetSourcePort(UDPHeader *const header,
                             const uint16_t source_port) {
   header->source_port = source_port;

+ 4 - 0
source/src/ports/udp_protocol.h

@@ -18,7 +18,11 @@
 
 #include <stdint.h>
 #include <stddef.h>
+#ifdef POSIX
 #include <netinet/in.h>
+#elif WIN32
+typedef uint32_t in_addr_t;
+#endif
 
 static size_t kUpdHeaderLength = 8U; /**< UDP header length in bytes */
 

+ 1 - 0
source/src/utils/doublylinkedlist.c

@@ -8,6 +8,7 @@
 
 #include "opener_user_conf.h"
 #include <stdio.h>  // Needed to define NULL
+#include <assert.h>
 
 void DoublyLinkedListInitialize(DoublyLinkedList *list,
                                 NodeMemoryAllocator allocator,