I have a set of macros that combined have more than 16,000 lines. After updating NASM to 2.15 and recompiling my codes, I was greeted with thousands of "Warning: dropping trailing empty parameter in call to macro" warnings. I can disable this by turning off the "macro-params-legacy" warning, but it is not a good practice. So I wonder how to deal with this properly.
Considering a simple example,
%macro _AND 2-3.nolist
AND %1, %2
%ifnempty %3
AND %1, %3
%endif
%endmacro
%macro _ANDOR 3-4.nolist
_AND %2, %3, %4
OR %1, %2
%endmacro
calling _ANDOR with three parameters leads to the above warning.
_ANDOR EAX, EBX, ECX
At first, I thought that the newly introduced %, operator could suppress the warning. But changing the code to
%macro _ANDOR 3-4.nolist
_AND %2, %3 %, %4
OR %1, %2
%endmacro
led to a syntax error. For now, the only way that I can think about is to use conditions
%macro _ANDOR 3-4.nolist
%ifempty %4
_AND %2, %3
%else
_AND %2, %3, %4
%endif
OR %1, %2
%endmacro
But this is error-prone, laborious, and ugly. So is there a simple way to avoid the warning?
BTW, I understand the point of adding this warning, but wonder when it was added, did anyone consider the above scenario? Because NASM allows macros to have greedy and range parameters, it seems to me that this is avoidable and NASM should provide a way to do it elegantly. Expanding the use of the %, operator seems a reasonable resolution to me.