Kaynağa Gözat

enable build on MSVC 2015 (lesser MSVC fail due to missing C99 constructs)

Julius Pfrommer 10 yıl önce
ebeveyn
işleme
382f17459f

+ 2 - 2
examples/networklayer_tcp.c

@@ -453,10 +453,10 @@ static UA_StatusCode ClientNetworkLayerTCP_connect(const UA_String endpointUrl,
     }
 
     //this is somewhat ugly, but atoi needs a c string
-    char cstringEndpointUrl[endpointUrl.length+1];
+    char *cstringEndpointUrl = UA_alloca(sizeof(char) * endpointUrl.length+1);
     memset(cstringEndpointUrl, 0, endpointUrl.length+1);
     memcpy(cstringEndpointUrl, endpointUrl.data, endpointUrl.length);
-    cstringEndpointUrl[endpointUrl.length+1] = '0';
+    cstringEndpointUrl[endpointUrl.length + 1] = '0';
 
     UA_UInt16 portpos = 9;
     UA_UInt16 port = 0;

+ 18 - 18
include/ua_log.h

@@ -50,45 +50,45 @@ typedef struct UA_Logger {
 } UA_Logger;
 
 #if UA_LOGLEVEL <= 100
-#define UA_LOG_TRACE(LOGGER, CATEGORY, MSG...) do { \
-        if(LOGGER.log_trace) LOGGER.log_trace(CATEGORY, MSG); } while(0)
+#define UA_LOG_TRACE(LOGGER, CATEGORY, ...) do { \
+        if(LOGGER.log_trace) LOGGER.log_trace(CATEGORY, __VA_ARGS__); } while(0)
 #else
-#define UA_LOG_TRACE(LOGGER, CATEGORY, MSG...) do {} while(0)
+#define UA_LOG_TRACE(LOGGER, CATEGORY, ...) do {} while(0)
 #endif
 
 #if UA_LOGLEVEL <= 200
-#define UA_LOG_DEBUG(LOGGER, CATEGORY, MSG...) do { \
-        if(LOGGER.log_debug) LOGGER.log_debug(CATEGORY, MSG); } while(0)
+#define UA_LOG_DEBUG(LOGGER, CATEGORY, ...) do { \
+        if(LOGGER.log_debug) LOGGER.log_debug(CATEGORY, __VA_ARGS__); } while(0)
 #else
-#define UA_LOG_DEBUG(LOGGER, CATEGORY, MSG...) do {} while(0)
+#define UA_LOG_DEBUG(LOGGER, CATEGORY, ...) do {} while(0)
 #endif
 
 #if UA_LOGLEVEL <= 300
-#define UA_LOG_INFO(LOGGER, CATEGORY, MSG...) do { \
-        if(LOGGER.log_info) LOGGER.log_info(CATEGORY, MSG); } while(0)
+#define UA_LOG_INFO(LOGGER, CATEGORY, ...) do { \
+        if(LOGGER.log_info) LOGGER.log_info(CATEGORY, __VA_ARGS__); } while(0)
 #else
-#define UA_LOG_INFO(LOGGER, CATEGORY, MSG...) do {} while(0)
+#define UA_LOG_INFO(LOGGER, CATEGORY, ...) do {} while(0)
 #endif
 
 #if UA_LOGLEVEL <= 400
-#define UA_LOG_WARNING(LOGGER, CATEGORY, MSG...) do { \
-        if(LOGGER.log_warning) LOGGER.log_warning(CATEGORY, MSG); } while(0)
+#define UA_LOG_WARNING(LOGGER, CATEGORY, ...) do { \
+        if(LOGGER.log_warning) LOGGER.log_warning(CATEGORY, __VA_ARGS__); } while(0)
 #else
-#define UA_LOG_WARNING(LOGGER, CATEGORY, MSG...) do {} while(0)
+#define UA_LOG_WARNING(LOGGER, CATEGORY, ...) do {} while(0)
 #endif
 
 #if UA_LOGLEVEL <= 500
-#define UA_LOG_ERROR(LOGGER, CATEGORY, MSG...) do { \
-        if(LOGGER.log_error) LOGGER.log_error(CATEGORY, MSG); } while(0)
+#define UA_LOG_ERROR(LOGGER, CATEGORY, ...) do { \
+        if(LOGGER.log_error) LOGGER.log_error(CATEGORY, __VA_ARGS__); } while(0)
 #else
-#define UA_LOG_ERROR(LOGGER, CATEGORY, MSG...) do {} while(0)
+#define UA_LOG_ERROR(LOGGER, CATEGORY, ...) do {} while(0)
 #endif
 
 #if UA_LOGLEVEL <= 600
-#define UA_LOG_FATAL(LOGGER, CATEGORY, MSG...) do { \
-        if(LOGGER.log_fatal) LOGGER.log_fatal(CATEGORY, MSG); } while(0)
+#define UA_LOG_FATAL(LOGGER, CATEGORY, ...) do { \
+        if(LOGGER.log_fatal) LOGGER.log_fatal(CATEGORY, __VA_ARGS__); } while(0)
 #else
-#define UA_LOG_FATAL(LOGGER, CATEGORY, MSG...) do {} while(0)
+#define UA_LOG_FATAL(LOGGER, CATEGORY, ...) do {} while(0)
 #endif
 
 /** @} */

+ 2 - 3
src/client/ua_client.c

@@ -433,7 +433,7 @@ UA_StatusCode UA_Client_connect(UA_Client *client, UA_ConnectionConfig conf,
 }
 
 
-UA_StatusCode UA_EXPORT UA_Client_disconnect(UA_Client *client) {
+UA_StatusCode UA_Client_disconnect(UA_Client *client) {
     UA_StatusCode retval;
     retval = CloseSession(client);
     if(retval == UA_STATUSCODE_GOOD)
@@ -499,8 +499,7 @@ UA_DeleteNodesResponse UA_Client_deleteNodes(UA_Client *client, UA_DeleteNodesRe
     return response;
 }
 
-UA_DeleteReferencesResponse UA_EXPORT
-UA_Client_deleteReferences(UA_Client *client, UA_DeleteReferencesRequest *request) {
+UA_DeleteReferencesResponse UA_Client_deleteReferences(UA_Client *client, UA_DeleteReferencesRequest *request) {
     UA_DeleteReferencesResponse response;
     synchronousRequest(request, &UA_TYPES[UA_TYPES_BROWSEREQUEST], &response,
                        &UA_TYPES[UA_TYPES_BROWSERESPONSE], client);

+ 1 - 1
src/server/ua_services_discovery.c

@@ -20,7 +20,7 @@ void Service_FindServers(UA_Server *server, const UA_FindServersRequest *request
 
 void Service_GetEndpoints(UA_Server *server, const UA_GetEndpointsRequest *request, UA_GetEndpointsResponse *response) {
     /* test if the supported binary profile shall be returned */
-    UA_Boolean relevant_endpoints[server->endpointDescriptionsSize];
+    UA_Boolean *relevant_endpoints = UA_alloca(sizeof(UA_Boolean)*server->endpointDescriptionsSize);
     size_t relevant_count = 0;
     for(UA_Int32 j = 0; j < server->endpointDescriptionsSize; j++) {
         relevant_endpoints[j] = UA_FALSE;