cross posted at 8052.com I have a module, which is used in four different products, that has way too many #ifdef's to be readable in debug and, at the same time, there is so much common code that making four separate modules is not the right approach. I have used all the "usual tricks" (separating what is only for one to a separate libray module, making some conditionals inside a macro etc) What I wonder is: is there some software that can "cut type x" out of the source before compilation. Since I am using a .bat operation (no IDE), a free standing program would be fine. This, probably, would require replacing the #ifdef with somrthing such a program "understood" no problem. Erik just so you know: I can NOT use the IDE due to its inability to make lots of slightly different builds in one go from the same source. Not a complaint, just a fact.
sure, but the bypassed code still show up in the source window on the emulator which can be a bit "limiting productivity". That only happens with the builtin preprocessor. What you're trying to do here amounts to running a separate preprocessor program on your code, and feeding C51 the already preprocessed output file. C51 would thus never see the "real" source file, and all debug info would point to the streamlined copies. But since that would mean that all macros are fully expanded, and you get the actual text of all from system headers, that's probably not what you want. Fully preprocessed output indeed tends to be even larger, and way more confusing, than its heavily #ifdef'ed input. What you need is a special subset of the C preprocessor as a separate program. That's exactly what "unifdef", which I mentioned before, is.
What you need is a special subset of the C preprocessor as a separate program. That's exactly what "unifdef", which I mentioned before, is. will that run in a normal (windows) environment? erik
will that run in a normal (windows) environment? Yes. It'll run even on plain DOS if you want it to. In the best tradition of Unix tools, it's a plain vanilla console application consisting of a single, 15 kB C source file. The only real caveat of this little thing is openly announced by its name: it really only handles #ifdef. Not #if defined(), and not general #if's.