Browse Source

added a gcc-version check around pragma
diagnostics as this is new since version 4.6

corrected version check

corrected version check

LEvertz 10 years ago
parent
commit
cc47eefbec
4 changed files with 8 additions and 8 deletions
  1. 2 2
      examples/logger_stdout.c
  2. 2 2
      examples/networklayer_udp.c
  3. 2 2
      src/server/ua_nodestore_hash.inc
  4. 2 2
      src/ua_types.c

+ 2 - 2
examples/logger_stdout.c

@@ -18,7 +18,7 @@ static void print_time(void) {
 const char *LogLevelNames[6] = {"trace", "debug", "info", "warning", "error", "fatal"};
 const char *LogCategoryNames[4] = {"communication", "server", "client", "userland"};
 
-#if defined(__GNUC__) || defined(__clang__)
+#if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4 || defined(__clang__))
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
 #endif
@@ -32,7 +32,7 @@ static void Logger_Stdout(UA_LogLevel level, UA_LogCategory category, const char
     printf("\n");
     va_end(ap);
 }
-#if defined(__GNUC__) || defined(__clang__)
+#if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4 || defined(__clang__))
 #pragma GCC diagnostic pop
 #endif
 

+ 2 - 2
examples/networklayer_udp.c

@@ -78,12 +78,12 @@ static void writeCallbackUDP(UDPConnection *handle, UA_ByteStringArray gather_bu
 	}
 	struct sockaddr_in *sin = NULL;
 	if (handle->from.sa_family == AF_INET) {
-#if defined(__GNUC__) || defined(__clang__)
+#if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4 || defined(__clang__))
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wcast-align"
 #endif
 	    sin = (struct sockaddr_in *) &(handle->from);
-#if defined(__GNUC__) || defined(__clang__)
+#if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4 || defined(__clang__))
 #pragma GCC diagnostic pop
 #endif
 	} else {

+ 2 - 2
src/server/ua_nodestore_hash.inc

@@ -18,12 +18,12 @@ static hash_t hash_array(const UA_Byte *data, UA_UInt32 len, UA_UInt32 seed) {
     static const uint32_t n  = 0xe6546b64;
     hash_t hash = seed;
     /* Somce compilers emit a warning when casting from a byte array to ints. */
-#if defined(__GNUC__) || defined(__clang__)
+#if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4 || defined(__clang__))
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wcast-align"
 #endif
     blocks = (const uint32_t *)data;
-#if defined(__GNUC__) || defined(__clang__)
+#if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4 || defined(__clang__))
 #pragma GCC diagnostic pop
 #endif
     for(int32_t i = 0;i < nblocks;i++) {

+ 2 - 2
src/ua_types.c

@@ -127,13 +127,13 @@ UA_StatusCode UA_String_copyprintf(char const fmt[], UA_String *dst, ...) {
     char src[UA_STRING_ALLOCPRINTF_BUFSIZE];
     va_list ap;
     va_start(ap, dst);
-#if defined(__GNUC__) || defined(__clang__)
+#if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4 || defined(__clang__))
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
 #endif
     // vsnprintf should only take a literal and no variable to be secure
     UA_Int32 len = vsnprintf(src, UA_STRING_ALLOCPRINTF_BUFSIZE, fmt, ap);
-#if defined(__GNUC__) || defined(__clang__)
+#if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4 || defined(__clang__))
 #pragma GCC diagnostic pop
 #endif
     va_end(ap);