From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id AD9BDA0524;
	Fri, 31 Jan 2020 04:08:01 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 200F61C0B0;
	Fri, 31 Jan 2020 04:07:56 +0100 (CET)
Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com
 [209.85.208.193]) by dpdk.org (Postfix) with ESMTP id 83FCC1C030
 for <dev@dpdk.org>; Fri, 31 Jan 2020 04:07:52 +0100 (CET)
Received: by mail-lj1-f193.google.com with SMTP id q8so5620337ljb.2
 for <dev@dpdk.org>; Thu, 30 Jan 2020 19:07:52 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=bXWEXN2ALw3di/Rr732lxI4x13ETr+1H/yyU6YvNjWA=;
 b=vDJ+meAPBA2mLzdyK+2FB/qmAQ7D7kpJUzp8oQdxPLHrDGopWXwVXKYUn18NsAXtVr
 49LL2ao4Dfexe2nSWjG6UW6FIpt8HriUcIP5oMW7P63Bg5IZeGyIy/G6yjpe4IpVeBYG
 ut4aqUG7sOXMkkh5RrY788cY0YfIYXp3JILrirkvEFwP77ba51hdyCVJtW37xnaF4+nU
 yR5F/yEi6FlH3iuS6YnNpftnpi0Him7Kd8zA7z24kFR+W2Wi3coo1YnnyJzVglBm6Lo/
 v6pCZvlqRmhhJDkeq3arrjoh2namHBEycD3Ky865doHiBv6FFw6ZjXRsz1UJGVqNm57S
 fqeg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=bXWEXN2ALw3di/Rr732lxI4x13ETr+1H/yyU6YvNjWA=;
 b=cCrwOjh8+MIhiBi6M6RNH/e5oTsSHjuKiKVwWWB4IFCkCLblF3GD5cUrIWWBrpM1t7
 iDpKEIT3PG1KzXo6GRfP0YqYxKTrxJlctdVoFtxnRpctLc1F2i1HYf1rBQgWv8ToZypg
 us4Q07YFzCyz15qJKXQta1D4o/R8vvFu5T9Q0jfD4TihlpihGVSVNmndAE4NdyhG8Bvg
 /TzpXsitsBghKNflczNuzA00X05cp1FUeyh920hp0zIUl5i/0Ruyfom+MVacVnCX5vkD
 ckLfNxaqUQuoL8lvcMHlgY6kpN4IZ5nu6zHrJT0zHV+JnOj6MiJtmQQbu0/19sk6h/rU
 6kmA==
X-Gm-Message-State: APjAAAWvZ6dPKbD7P86acF1p0nX7trMND8sgK18ziXaacc3JUW4VWuYC
 HKHhcwiJVn4yHf5xL6x0G12x9ox5JtUwZQ==
X-Google-Smtp-Source: APXvYqysbQMdY8/269881Dh5tZXIogQV05ZhlOw7k0Y/gz6eYJ/V9RirdWcXBWiytp5flsOIoDIP5A==
X-Received: by 2002:a2e:8907:: with SMTP id d7mr4845533lji.71.1580440071858;
 Thu, 30 Jan 2020 19:07:51 -0800 (PST)
Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru.
 [37.110.65.23])
 by smtp.googlemail.com with ESMTPSA id e12sm3630332lfc.70.2020.01.30.19.07.51
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 30 Jan 2020 19:07:51 -0800 (PST)
From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: dev@dpdk.org
Cc: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Date: Fri, 31 Jan 2020 06:07:39 +0300
Message-Id: <20200131030744.19596-2-dmitry.kozliuk@gmail.com>
X-Mailer: git-send-email 2.25.0
In-Reply-To: <20200131030744.19596-1-dmitry.kozliuk@gmail.com>
References: <20200131030744.19596-1-dmitry.kozliuk@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH 1/6] eal: introduce portable format attribute
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

When using __attribute__((format(...)) on functions, GCC on Windows
assumes MS-specific format string by default, even if the underlying
stdio implementation is ANSI-compliant (either MS Unicersal CRT
or MinGW implementation). Wrap attribute into a macro that forces
GNU-specific format string when using GCC.

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>

diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 4b5f3a31f..2f086bb9c 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -89,6 +89,21 @@ typedef uint16_t unaligned_uint16_t;
  */
 #define RTE_SET_USED(x) (void)(x)
 
+/**
+ * Check format string and its arguments at compile-time.
+ *
+ * GCC on Windows assumes MS-specific format string by default,
+ * even if the underlying stdio implementation is ANSI-compliant,
+ * so this must be overridden.
+ */
+#if defined(RTE_TOOLCHAIN_GCC)
+#define __rte_format(archetype, format_index, first_arg) \
+	__attribute__((format(gnu_##archetype, format_index, first_arg)))
+#else
+#define __rte_format(archetype, format_index, first_arg) \
+	__attribute__((format(archetype, format_index, first_arg)))
+#endif
+
 #define RTE_PRIORITY_LOG 101
 #define RTE_PRIORITY_BUS 110
 #define RTE_PRIORITY_CLASS 120
-- 
2.25.0