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

WARNING L1

I have problem:
A warning L1 with unresolved external symbol, with file SERINIT.h, Why??

Parents
  • This means that your code refers to the symbol, but has not defined it.
    A "Symbol" is the name of a function or variable.

    eg, if you #include stdio.h this gives you Prototypes for functions like printf, etc, but it does not contain the actual definitions of those functions; ie, it does not contain the code which actually does the work of printf.
    Your code just assumes that the body of printf will be provided from somewhere else (hence "external"), and that the interface is as shown by the Prototype.
    Usually, printf, etc, are provided in Libraries - and if you forget to link to the Library, you will get this warning from the Linker.

    Your Linker message should include the name of the symbol (note that it will be converted to ALL UPPERCASE); the Browser should show you that this is referenced but never defined.

    Maybe you've forgotten to link a Library, or just omitted the definition, or it could be "lost" within a #if...#endif?

    A name like "serinit" sounds like it could be to do with the initialisation of serial comms? Maybe it provides external declarations for Buffers, Ports, interrupt handlers, or similar, but requires you to provide the actual definitions within your implementation?

    Does the Linker message actually mention serinit.h?
    Normally you wouldn't compile a .h file on its own, so the Linker would never know its name (there would be no serinit.obj) - the message would refer to the .c file which #included it.
    (It's not wrong to compile a .h file - just not so common).

Reply
  • This means that your code refers to the symbol, but has not defined it.
    A "Symbol" is the name of a function or variable.

    eg, if you #include stdio.h this gives you Prototypes for functions like printf, etc, but it does not contain the actual definitions of those functions; ie, it does not contain the code which actually does the work of printf.
    Your code just assumes that the body of printf will be provided from somewhere else (hence "external"), and that the interface is as shown by the Prototype.
    Usually, printf, etc, are provided in Libraries - and if you forget to link to the Library, you will get this warning from the Linker.

    Your Linker message should include the name of the symbol (note that it will be converted to ALL UPPERCASE); the Browser should show you that this is referenced but never defined.

    Maybe you've forgotten to link a Library, or just omitted the definition, or it could be "lost" within a #if...#endif?

    A name like "serinit" sounds like it could be to do with the initialisation of serial comms? Maybe it provides external declarations for Buffers, Ports, interrupt handlers, or similar, but requires you to provide the actual definitions within your implementation?

    Does the Linker message actually mention serinit.h?
    Normally you wouldn't compile a .h file on its own, so the Linker would never know its name (there would be no serinit.obj) - the message would refer to the .c file which #included it.
    (It's not wrong to compile a .h file - just not so common).

Children
  • Sorry: must read posts more carefully!

    The warning L1, "UNRESOLVED EXTERNAL SYMBOL," means that you have declared an 'extern' without providing a corresponding public definition.
    In itself this is not a problem - it just means that you have an unnecessary 'extern' for a symbol which you don't use.

    The problem comes when you also get warning L2, "REFERENCE MADE TO UNRESOLVED EXTERNAL" - which means that you've actually tried to use the unknown symbol.
    It still could be OK; eg, if you're doing a partial link, or making a Library.

    See p335 of "Macro Assembler and Utilities for 8051 and Variants User's Guide 07.2000"