[clang] Extension: allow recursive macros (PR #65851)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 11 05:56:40 PDT 2023


kelbon wrote:

> this needs an RFC to be posted to Discourse so the community is aware of the potential new language extension

I will create it soon

> 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.

I think this should be determined during the discussion, another possible name is `define_recursive` (but its not requireid to be recursive..)

> 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

Yes, thats problem, every extension even not in preprocessor have same problems, but I think there are many projects now which use only clang and if people like the idea possibly it will be gcc extension too

> It's also worth noting that you can write recursive macros in C

As far as I know, the maximum that can be done is to code-generate many very difficult-to-understand constructs that allow you to repeat your code up to N times, creating the illusion of recursion and I would like to fix it

https://github.com/llvm/llvm-project/pull/65851


More information about the cfe-commits mailing list