Skip to content

Fix -Wgnu-zero-variadic-macro-arguments Clang warning in plugin_interface.hpp (#560)#635

Closed
ROKUMATE wants to merge 2 commits intometacall:developfrom
ROKUMATE:issue-560-fix
Closed

Fix -Wgnu-zero-variadic-macro-arguments Clang warning in plugin_interface.hpp (#560)#635
ROKUMATE wants to merge 2 commits intometacall:developfrom
ROKUMATE:issue-560-fix

Conversation

@ROKUMATE
Copy link
Contributor

Summary

Fixes #560 — Clang emits -Wgnu-zero-variadic-macro-arguments warnings when
EXTENSION_FUNCTION and EXTENSION_FUNCTION_CHECK are called with zero extra
arguments (e.g. EXTENSION_FUNCTION_CHECK(INSPECT_ERROR)).

Root Cause

Both macros use PREPROCESSOR_ARGS_EMPTY(__VA_ARGS__) to branch between a void
and a parameterised path. This is intentional and correct, but Clang flags the
zero-argument __VA_ARGS__ expansion as a GNU extension.

Fix

Added a #pragma clang diagnostic ignored guard at the top of
plugin_interface.hpp, scoped to #if defined(__clang__), suppressing the
diagnostic only for this file where the pattern is intentional.

#if defined(__clang__)
    #pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#endif

No logic changes — purely a diagnostic suppression with an explanatory comment.

Files Changed

source/plugin/include/plugin/plugin_interface.hpp — added pragma guard

@viferga
Copy link
Member

viferga commented Mar 2, 2026

This is not the correct way of solving it. I have mentioned a way of doing it in the issue:

#include <stdio.h>

// Internal helper macros
#define _LOG_GET_MACRO(_1,_2,NAME,...) NAME

#define LOG1(fmt)           printf(fmt)
#define LOG2(fmt, ...)      printf(fmt, __VA_ARGS__)

// Public macro
#define LOG(...) _LOG_GET_MACRO(__VA_ARGS__, LOG2, LOG1)(__VA_ARGS__)

@viferga viferga closed this Mar 2, 2026
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.

Preprocessor warnings with Clang

2 participants