Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 20, 2022

Conversation

mansourmoufid
Copy link
Contributor

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
Copy link
Member

jrsnen commented Jul 20, 2022

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

@jrsnen jrsnen merged commit cb7ef9d into ultravideo:master Jul 20, 2022
@mansourmoufid mansourmoufid deleted the log-clang-warnings branch July 21, 2022 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ISO C++11 requires at least one argument for the "..." in a variadic macro - warnings
2 participants