Variadic macro no comma

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
Post Reply
Rule
Posts: 16
Joined: Nov 03, 2020 19:04
Contact:

Variadic macro no comma

Post by Rule »

Consider the snippet below. When you omit the last argument to a variadic macro, you may omit the preceding comma as well.

Code: Select all

#define FOO(a,b...) print a;b

FOO()
FOO(,)
FOO(x)
FOO(x,)
FOO(x,y,z)
Expands without any problem to:

Code: Select all

 print ;
 print ;
 print x;
 print x;
 print x;y,z
 
Perhaps not a big deal, but still a nice feature I think.
Post Reply