RFC: C preprocessor extension: Multiline/block macro definition
Alvaro Saez
alvarosaez316@gmail.com
Fri Jul 24 12:07:06 GMT 2026
Apologies for the misconfigured alias, that should be fixed now.
El vie, 24 jul 2026 a las 14:03, NomagnoIsNotDead (<alvarosaez316@gmail.com>)
escribió:
> 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 command
> 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 with
> contributing to large free software projects, so any advice is appreciated.
>
> Cheers,
> Alvaro Saez AKA Nomagno.
>
More information about the Gcc
mailing list