logological / gpp

GPP, a generic preprocessor
https://logological.org/gpp
GNU Lesser General Public License v3.0
197 stars 31 forks source link

Variadic macros #52

Open Artoria2e5 opened 3 years ago

Artoria2e5 commented 3 years ago

A significant shortfall between gpp and cpp appears to be variadic macros. People have asked for it in Fortran and in JavaScript.

This would require expanding the meta definition to have:

Or an interesting alternative/parallel expansion is to expand the argument reference sequence to handle ranges. The new stuff will look like... maybe #{num}.

Both cases still need some magic to remove the comma with an empty expansion.

vilkov commented 3 years ago

Support of variadic macro would be great!

logological commented 3 years ago

Patches welcome.

Artoria2e5 commented 3 years ago

I seem to have worked on the #{num} thing for a while at https://github.com/Artoria2e5/gpp/tree/var, but there's no way I have tested it. I have no idea what got into my head to handwrite a state machine. Even if it works the comma magic still needs to be added -- __VA_OPT__ in cpp.