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

Avoiding warning L16

Hello,

Is there a way to avoid the following warning: Warning L16: uncalled segment, ignored for overlay process? I'm not talking about the Disable warning numbers you have in the options of a project...

I know what the overlay process does, but if the function is indeed not called (and there could be reasons not to call a function for a certain application), is there not a kind of 'dead code remover' who can check if a function is called or not?

If so, is this function not able to inform the compiler just to ignore this function and not to generate the warning?

Rgds,

Geert

  • If you include a function in an object file that you pass to the linker, you are explicitly telling the linker to include the function no matter what.

    If you want to create functions that are selectively included based on whether they are called, you must use a library. Each object in the library should contain exactly one function.

    Then, if a function is not used, it is not included from the library.

    Jon

  • There was a long thread on this a while ago - try a search.

    "inform the compiler just to ignore this function"

    You mean Linker.

    Do any of the techniques here help:
    http://www.keil.com/appnotes/docs/apnt_129.asp
    There's also a knowledgebase article on function pointers

  • For this I wrote a simple program that scans L51 listing for warnings 16. If there are warnings 16, it writes out an overlay description that binds all unreferenced segments (warning 16) to main, like this: OVERLAY( main ! (seg1,seg2,etc))
    Then I re-link with this overlay directive - no more warnings.

    My app also generates some warnings 15 (multiple called segment) that actually should be ignored. So my program searches for these as well, and excludes from overlaying by OVERLAY( segname !*)

    Fast, dirty, practical :)

    P.S. - I made this thingie in the dark days of C51 v 3.20 - may be modern linkers have some new controls for this.

  • Hi Andrew,

    Yes, I mean indeed the linker, not the compiler. Sorry for mentioning the wrong tool.

    Thanks anyway for the useful input. The input given by Jon is also worth looking at. Maybe creating a library is the solution in my case. I'll have a closer look at it.

    Rgds,

    Geert


  • "Each object in the library should contain exactly one function."

    This requirement is a bit restrictive in practice. Normal C code will contain many functions in a .c file, and thus the corresponding object. Building a library then won't help, since if you include _any_ function from a single object, you'll get the warnings for all the other functions you didn't want from that object. The only way to avoid it is to break every function into its own file, which is a bit nightmarish from an organizational point of view, particularly when several functions share data or helper routines that don't need to be externally visible.

    The toolchain should be smart enough to pull in only those functions you actually call from a library. It would also be good if the linker could eliminate unreferenced functions from an object, even if it's not a library. Every other compiler I've used supports this functionality.

  • Every other compiler I've used supports this functionality.

    Really? Are you certain about that? I don't know of a linker that will break objects apart.

    Jon