ultravideo / uvgRTP

An open-source library for RTP/SRTP media delivery
BSD 2-Clause "Simplified" License
325 stars 92 forks source link

common: Remove GNU extension (, ##__VA_ARGS__). #149

Closed mansourmoufid closed 2 years ago

mansourmoufid commented 2 years ago

A zero-length __VA_ARGS__ would result in a trailing comma, which is a syntax error. GCC supports zero-length __VA_ARGS__ with an extension to eat the comma: , ## __VA_ARGS__.

But this is not standard and since CMakeLists.txt sets -Wall -Wextra -Wpedantic, we get a ton of spurious warnings when building with clang:

uvgRTP-master/include/uvgrtp/debug.hh:56:27: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]
            "", __func__, ##__VA_ARGS__)
                          ^

So the function uvgrtp_debug can be implemented as a variadic function (which unlike variadic macros, do support zero-length va_list).

jrsnen commented 2 years ago

This is great! Thank you! Those warnings have been annoying on Linux.