This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

something about preprocessor

when i use preprocessor
#if 0
...
#endif

to cross out a bunch of sentences, then after building the target.
I noticed the "data" memory usage increased, why?
There is no error in the result.

Parents
  • Would [REMOVEUNUSED] help?

    I haven't tried it personally. But according to my co-workers that have, it doesn't really do what I hoped. That is, the call tree still explodes unless we manually take out unused functions.

    But maybe they're not using the new feature quite right. I'll have to investigate.

Reply
  • Would [REMOVEUNUSED] help?

    I haven't tried it personally. But according to my co-workers that have, it doesn't really do what I hoped. That is, the call tree still explodes unless we manually take out unused functions.

    But maybe they're not using the new feature quite right. I'll have to investigate.

Children
  • "That is, the call tree still explodes unless we manually take out unused functions."

    I suppose what's really required is a compiler directive such as:

    #pragma IDONTUSEFUNCTIONPOINTERS

  • That is, the call tree still explodes unless we manually take out unused functions.

    That may have been caused by the linker not being able to tell that these were unused. If, as the other reply hinted, function pointers are involved in any way, it's provably impossible to do call tree analysis in the general case, i.e. the linker has to drop the ball at some point.

    In an (admittedly minimalistic) example I just tried, it worked just fine: the un-called function and its data segment show up in the map file only in a new segment list titled "REMOVED SEGMENTS": they don't appear in the call tree, nor in the final program.