vinnylinux
vinnylinux

Reputation: 7024

Expanding macro globally: is it possible to automate?

I'm working on a really crappy codebase. To give you an idea, here's how they do loops:

#define loop(v,m) for(int v = 0; v < int(m); ++v)

This is done everywhere. And it gets even worse:

#define loopi(m) loop(i, m)
#define loopj(m) loop(j, m)
#define loopk(m) loop(k, m)
#define loopl(m) loop(l, m)
#define looprev(v, m) for (int v = int(m); --v >= 0;)
#define loopirev(m) looprev(i, m)
#define loopjrev(m) looprev(j, m)
#define loopkrev(m) looprev(k, m)
#define looplrev(m) looprev(l, m)

I have tried Eclipse's macro expansion refactoring tool, but it crashes. Is there a tool that can help me with this? This is just one of the hundreds of macros like this.

Upvotes: 1

Views: 84

Answers (1)

HighCommander4
HighCommander4

Reputation: 52799

I'm not aware of any built-in way to automate this with Eclipse CDT.

You could probably write an Eclipse plugin to automate it, although if manually invoking "Explore Macro Expansion" (I assume that's what you're referring to in your question) crashes, then your plugin is likely to run into the same crash. I would suggest filing a bug about that crash either way.

You could also look into other tools like clang-expand.

Upvotes: 1

Related Questions