NASM Forum > Using NASM

Warning: dropping trailing empty parameter

(1/1)

fullofbugs:
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,


--- Code: ---%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

--- End code ---

calling _ANDOR with three parameters leads to the above warning.


--- Code: ---        _ANDOR EAX, EBX, ECX

--- End code ---

At first, I thought that the newly introduced %, operator could suppress the warning. But changing the code to


--- Code: ---%macro _ANDOR 3-4.nolist
  _AND  %2, %3 %, %4
  OR    %1, %2
%endmacro

--- End code ---

led to a syntax error. For now, the only way that I can think about is to use conditions


--- Code: ---%macro _ANDOR 3-4.nolist
  %ifempty %4
    _AND  %2, %3
  %else
    _AND  %2, %3, %4
  %endif
  OR    %1, %2
%endmacro

--- End code ---

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.

fullofbugs:
After further trying, this is the way to do it. It is quite decent actually.


--- Code: ---%macro _ANDOR 3-4.nolist
  _AND  %2, %3 %, {%4}
  OR    %1, %2
%endmacro
--- End code ---

Frank Kotler:
Excellent! Thank you.

Best,
Frank

Navigation

[0] Message Index

Go to full version