[00/15] use GCC/MSVC compatible __VA_ARGS__

Message ID 1707774557-16012-1-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
Headers
Series use GCC/MSVC compatible __VA_ARGS__ |

Message

Tyler Retzlaff Feb. 12, 2024, 9:49 p.m. UTC
  MSVC does not support GCC args... forwarding of args replace
with ... and __VA_ARGS__ when forwarding.  Both forms of
forwarding are a compiler extension but the latter is supported
by both MSVC and GCC.

I have not been able to exhaustively test all versions of GCC so
please provide feedback as appropriate.

Tyler Retzlaff (15):
  eal: use GCC and MSVC common VA ARGS extension
  bpf: use GCC and MSVC common VA ARGS extension
  cfgfile: use GCC and MSVC common VA ARGS extension
  cmdline: use GCC and MSVC common VA ARGS extension
  ip_frag: use GCC and MSVC common VA ARGS extension
  compressdev: use GCC and MSVC common VA ARGS extension
  metrics: use GCC and MSVC common VA ARGS extension
  mldev: use GCC and MSVC common VA ARGS extension
  net: use GCC and MSVC common VA ARGS extension
  pdump: use GCC and MSVC common VA ARGS extension
  power: use GCC and MSVC common VA ARGS extension
  rawdev: use GCC and MSVC common VA ARGS extension
  rcu: use GCC and MSVC common VA ARGS extension
  stack: use GCC and MSVC common VA ARGS extension
  vhost: use GCC and MSVC common VA ARGS extension

 lib/bpf/bpf_impl.h                         |  4 ++--
 lib/cfgfile/rte_cfgfile.c                  |  4 ++--
 lib/cmdline/cmdline_parse.c                |  2 +-
 lib/cmdline/cmdline_parse_num.c            |  4 ++--
 lib/compressdev/rte_compressdev_internal.h |  4 ++--
 lib/eal/common/eal_trace.h                 |  8 ++++----
 lib/ip_frag/ip_frag_common.h               |  4 ++--
 lib/metrics/rte_metrics_telemetry.c        | 12 ++++++------
 lib/mldev/rte_mldev.h                      |  4 ++--
 lib/net/rte_net_crc.c                      |  4 ++--
 lib/pdump/rte_pdump.c                      |  4 ++--
 lib/power/power_common.h                   |  6 +++---
 lib/rawdev/rte_rawdev_pmd.h                | 18 +++++++++---------
 lib/rcu/rte_rcu_qsbr.c                     |  4 ++--
 lib/rcu/rte_rcu_qsbr.h                     | 12 ++++++------
 lib/stack/stack_pvt.h                      | 16 ++++++++--------
 lib/vhost/vhost.h                          |  8 ++++----
 lib/vhost/vhost_crypto.c                   | 14 +++++++-------
 18 files changed, 66 insertions(+), 66 deletions(-)
  

Comments

Bruce Richardson Feb. 13, 2024, 9 a.m. UTC | #1
On Mon, Feb 12, 2024 at 01:49:02PM -0800, Tyler Retzlaff wrote:
> MSVC does not support GCC args... forwarding of args replace
> with ... and __VA_ARGS__ when forwarding.  Both forms of
> forwarding are a compiler extension but the latter is supported
> by both MSVC and GCC.
> 
> I have not been able to exhaustively test all versions of GCC so
> please provide feedback as appropriate.
> 
> Tyler Retzlaff (15):
>   eal: use GCC and MSVC common VA ARGS extension
>   bpf: use GCC and MSVC common VA ARGS extension
>   cfgfile: use GCC and MSVC common VA ARGS extension
>   cmdline: use GCC and MSVC common VA ARGS extension
>   ip_frag: use GCC and MSVC common VA ARGS extension
>   compressdev: use GCC and MSVC common VA ARGS extension
>   metrics: use GCC and MSVC common VA ARGS extension
>   mldev: use GCC and MSVC common VA ARGS extension
>   net: use GCC and MSVC common VA ARGS extension
>   pdump: use GCC and MSVC common VA ARGS extension
>   power: use GCC and MSVC common VA ARGS extension
>   rawdev: use GCC and MSVC common VA ARGS extension
>   rcu: use GCC and MSVC common VA ARGS extension
>   stack: use GCC and MSVC common VA ARGS extension
>   vhost: use GCC and MSVC common VA ARGS extension
> 
Series-acked-by: Bruce Richardson <bruce.richardson@intel.com>
  
Morten Brørup Feb. 13, 2024, 9:09 a.m. UTC | #2
> From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> Sent: Monday, 12 February 2024 22.49
> 
> MSVC does not support GCC args... forwarding of args replace
> with ... and __VA_ARGS__ when forwarding.  Both forms of
> forwarding are a compiler extension but the latter is supported
> by both MSVC and GCC.

Series-acked-by: Morten Brørup <mb@smartsharesystems.com>
  
Thomas Monjalon Feb. 18, 2024, 1:38 p.m. UTC | #3
12/02/2024 22:49, Tyler Retzlaff:
> MSVC does not support GCC args... forwarding of args replace
> with ... and __VA_ARGS__ when forwarding.  Both forms of
> forwarding are a compiler extension but the latter is supported
> by both MSVC and GCC.

You use the non-standard ", ## __VA_ARGS__"
which would not compile in pedantic modes,
and possibly with other compilers.

I remember a private chat where I recommended you to use this:

lib/eal/include/rte_common.h
/**
 * ISO C helpers to modify format strings using variadic macros.
 * This is a replacement for the ", ## __VA_ARGS__" GNU extension.
 * An empty %s argument is appended to avoid a dangling comma.
 */
#define RTE_FMT(fmt, ...) fmt "%.0s", __VA_ARGS__ ""
#define RTE_FMT_HEAD(fmt, ...) fmt
#define RTE_FMT_TAIL(fmt, ...) __VA_ARGS__

Why not using it?