nasm/test/gsmacro.asm
H. Peter Anvin (Intel) a1a844697d preproc: fix varadic macros, add conditional comma operator
Fix the (severely broken handling of) varadic macros.

Add a conditional comma operator "%,". This expands to a comma unless
followed by a null expansion of some sort, which allows suppressing
the comma before an empty argument (usually varadic, but not
necessarily.)

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-08-20 01:32:28 -07:00

6 lines
121 B
NASM

%define greedy(a,b,c+) a + 66 %, b * 3 %, c
db greedy(1,2)
db greedy(1,2,3)
db greedy(1,2,3,4)
db greedy(1,2,3,4,5)