C macros with new lines in generated code

I need macro which expands into multiple lines of code. For example:

#define foo(...)
foo(something, something_else, ...)
...

Should be converted into:

something
something_else
...

And not into:

something something_else ...

Also if you wonder why I need such thing. I need to generate such code, new line is part of inline assembly syntax.

_asm
{
    mov eax, 3
    div 5
}

I’m interested in any form of achieving this, so all suggestions are welcome.

Just an idea after reading this answer. Would it be possible to have a macro for new line and call foo(something, NL, something_else, NL, ...)?


I’m also more interested into variadic version but knowing simpler version may also help.


Source: c#

Leave a Reply