Looking at similar question it seems like Eclipse CDT has exactly the functionality you need and the other question actually tells where you can set your ifdefs.
Emacs has something similar in form of hide-ifdef-mode
.
But you can also try to use IDE-agnostic solution like running the code through unifdef
and working with the result. If you just need to read the code, it's almost perfect solution. If you need to make some changes, things become a bit more complicated, but you can use git then to manage changes, like:
- import whole code base into git
- run through
unifdef
- commit the result, that's the basis for your patches
- work with the code base in whatever IDE/editor you prefer, commiting changes as usual
- if there is a need to produce patches for original code base, just checkout the original import commit and cherry-pick (or rebase) your patches from your branch (of course there is a chance for conflict, but it should be quite easy to resolve as you know your intended change for the code from the patch and you just need to adjust for ifdefs)
- if there is a need to update code base, just start from original import, apply an update, commit that, run through unifdef, commit that and then rebase your changes on top of that
Of course, whether this approach will work or not depends on particular code base and what you're going to do with it, but it can be useful in some scenarios.