[clang] Extension: allow recursive macros (PR #65851)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 11 05:05:37 PDT 2023
AaronBallman wrote:
I'd like to echo what @cor3ntin suggested above -- this needs an RFC to be posted to Discourse so the community is aware of the potential new language extension. We have a set of criteria for what we're looking for in such an RFC: https://clang.llvm.org/get_involved.html#criteria -- having the patch is a great start though as you can link to the patch from the RFC to give people a more concrete idea of what's being proposed.
> Yes, the name define2 is a placeholder, but the more I look at it, the more it looks appropriate
I'm not certain it's a particularly good name in terms of standardization as there's no way for users to distinguish between `define` and `define2`.
> Maybe, but I dont think standard committee will consider the proposal without reference implementation(if its not a modules ofc)) and, in case of preprocessor, usage in 'real world'
There's a chicken-and-egg problem. The committee wants to see implementation experience and the community wants to see support from the committee for larger ideas (we don't really want to add language extensions over objections from a standards committee unless there's sufficiently compelling reasons to do so).
I have not yet had the chance to review the code changes, but I do have some concerns at a high-level. Preprocessor language extensions are a bit difficult because of adoption issues. Unless other implementations also implement the same extension, a significant number of folks wind up needing to use preprocessor conditionals to skip the new feature and write fallback code so their macros remain portable, but once you write that fallback code, you no longer need the extension code in the first place. When writing your RFC, it would be good to mention whether you've been talking to other implementations and what their thoughts, opinions, and concerns are. It's also worth noting that you *can* write recursive macros in C, though it's not easy without use of a macro library like [P99](https://gustedt.gitlabpages.inria.fr/p99/p99-html/index.html).
https://github.com/llvm/llvm-project/pull/65851
More information about the cfe-commits
mailing list