3 ms·
Emacs has a "c-macro-expand" function which is quite hackish but extremely useful, IMO: it attempts to macro expand the region. For instance running it on the
by simias 13y ago
Emacs has a "c-macro-expand" function which is quite hackish but extremely useful, IMO: it attempts to macro expand the region.
For instance running it on the following code in the middle of a C source file:
#define BOGO_MAX(a, b) a > b ? a : b
int test()
{
return BOGO_MAX(3 + 4, 5);
}
Creates a new buffer containing:
int test()
{
return 3 + 4 > 5 ? 3 + 4: 5;
}
- tedunangst 13y agoHow well does that play with ifdef? The problem is rarely what does this macro expand to, but which macro is going to be expanded.
- simias 13y agoWell, I guess it depends on what your code looks like. That being said if I'm not sure if some code is being compiled I just add an "#error foo" and rebuild. Or even simpler I just type in some garbage to trigger a compilation error.