Re: RFC: C preprocessor extension: Multiline/block macro definition

Alvaro Saez via Gcc <[email protected]> Fri, 24 Jul 2026 14:07:06 +0200
Newsgroups gmane.comp.gcc.devel
Message-ID <CALzUo85h6he_sFtkyafxQmHFodB7vCq8fp3tk4UA3eKWNudu5A@mail.gmail.com>
Apologies for the misconfigured alias, that should be fixed now.

El vie, 24 jul 2026 a las 14:03, NomagnoIsNotDead (<[email protected]=
>)
escribi=C3=B3:

> Greetings!
>
> I have an idea to extend the GNU C preprocessor with a new kind of
> directive. Its behaviour should be sufficiently encapsulated by the
> following simple example:
>
> #startdef MACRO_NAME
>     You may define multiline macros here.
>     No backslashes are needed.
> #enddef
>
> Specifically, a multiline macro definition block is started by #startdef,
> and any text within is interpreted as part of the macro definition. Any
> appearance of #enddef at the beginning of a line within this block will
> terminate the macro definition. It can be thought of as the traditional C
> comment /*text*/-analogue to C++-style comments //text, but for macros.
>
> It is a purely ergonomic feature for writing large, multi-line macros in =
a
> slightly more maintainable manner.
>
> I made a prototype in the form of a wrapper around cc1 with the -B comman=
d
> line option that converts #startdef-#enddef blocks to regular #define s,
> but that approach has clear limitations so I am starting work in an
> implementation as a libcpp feature.
>
> I know GNU C is generally open to adding certain extensions, but I also
> know this feature touches one of the more forward-facing parts of GCC. So=
 I
> would like to ask for feedback and opinions before committing to making a
> patch that fulfills the relatively significant requirements in the GCC
> contribution guidelines for the C frontend. I am not very experienced wit=
h
> contributing to large free software projects, so any advice is appreciate=
d.
>
> Cheers,
> Alvaro Saez AKA Nomagno.
>