News for hackers. Stuff that matters.
Re:My Favorite C++ Pattern: X Macros (2023) by writebetterc on Tuesday March 25, 2025 @11:13AM (#43472340)
IDEs understand preprocessor macros, so IDE features (jump2def, etc) work with this. IDEs also can expand the macro invocations. So, I prefer the macros when possible :-).
Re:My Favorite C++ Pattern: X Macros (2023) by Someone on Tuesday March 25, 2025 @12:16PM (#43473017)
> IDEs understand preprocessor macros, so IDE features (jump2def, etc) work with this.

Do they? X macros often are used with token pasting (https://gcc.gnu.org/onlinedocs/cpp/Concatenation.html), as for example in (FTA)

  #define AST_BEGIN_SUBCLASSES(NAME) START_##NAME ,
Are modern IDEs/compiler toolchains smart enough to tell you that START_foo was created by an expansion of that macro?
Re:My Favorite C++ Pattern: X Macros (2023) by jcelerier on Tuesday March 25, 2025 @12:29PM (#43473162)
any non-toy IDE can do that. Most IDEs use clang directly for parsing nowadays.
Re:My Favorite C++ Pattern: X Macros (2023) by tom_ on Tuesday March 25, 2025 @01:08PM (#43473545)
Yes. I use this with VS2019 for generating enum names, and they interact fine with auto complete and go to definition.