Also use PG_PRINTF_ATTRIBUTE instead of printf in __attribute__((format(printf, .., ..))) function attribute.
#ifndef __CONNECTION_H__
#define __CONNECTION_H__
-#ifdef __INCLUDE_POSTGRES_FE_H__ /* currently not defined */
-/*
- * Unfortunately #including postgres_fe.h causes various trobles.
- */
-#include "postgres_fe.h"
-#else /* currently */
-#if defined(__GNUC__) || defined(__IBMC__)
-#define PG_PRINTF_ATTRIBUTE gnu_printf
-#define pg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a)))
-#else
-#define pg_attribute_printf(f,a)
-#endif /* __GNUC__ || __IBMC__ */
-#endif /* __INCLUDE_POSTGRES_FE_H__ */
-
+#include "psqlodbc.h"
#include <libpq-fe.h>
#include "pqexpbuffer.h"
-#include "psqlodbc.h"
#include <time.h>
#include <stdlib.h>
#ifndef HAVE_STRLCAT
size_t strlcat(char *, const char *, size_t);
#endif /* HAVE_STRLCAT */
-int snprintfcat(char *buf, size_t size, const char *format, ...) __attribute__((format(printf,3,4)));
+int snprintfcat(char *buf, size_t size, const char *format, ...) __attribute__((format(PG_PRINTF_ATTRIBUTE,3,4)));
size_t snprintf_len(char *buf, size_t size, const char *format, ...);
char *my_trim(char *string);
#endif
#ifndef __GNUC__
-#define __attribute__(x)
+#define __attribute__(x)
#endif
-DLL_DECLARE int mylog(const char *fmt,...) __attribute__((format(printf, 1, 2)));
-DLL_DECLARE int myprintf(const char *fmt,...) __attribute__((format(printf, 1, 2)));
+DLL_DECLARE int mylog(const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
+DLL_DECLARE int myprintf(const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
-extern int qlog(char *fmt,...) __attribute__((format(printf, 1, 2)));
-extern int qprintf(char *fmt,...) __attribute__((format(printf, 1, 2)));
+extern int qlog(char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
+extern int qprintf(char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
const char *po_basename(const char *path);
#include <stdlib.h>
#endif /* WIN32 */
-#ifndef __GNUC__
+#ifdef __INCLUDE_POSTGRES_FE_H__ /* currently not defined */
+/*
+ * Unfortunately #including postgres_fe.h causes various trobles.
+ */
+#include "postgres_fe.h"
+#else /* currently */
+#if defined(__GNUC__) || defined(__IBMC__)
+#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 404
+#define PG_PRINTF_ATTRIBUTE gnu_printf
+#else
+#define PG_PRINTF_ATTRIBUTE printf
+#endif
+#define pg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a)))
+#else
#define __attribute__(x)
-#endif /* __GNUC__ */
+#define pg_attribute_printf(f,a)
+#endif /* __GNUC__ || __IBMC__ */
+#endif /* __INCLUDE_POSTGRES_FE_H__ */
#ifdef _MEMORY_DEBUG_
void *pgdebug_alloc(size_t);