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

Compiler name mangling

Hi,
Having wondered why the linker couldn't locate a code segment which I'd specified as part of the BL51 command line, I took a look at listing file to discover that the compiler had (somewhat arbitrarily) appended an underscore to some of the function names, hence the link error. Is there a means of inhibiting (or predicting)this annoying compiler characteristic?

Thanks!

  • Well, the first port of call for all such questions is always the Compiler manual! ;-)

    You didn't say which toolset - I assume we're talking C51?

    When you say "append" I assume you mean "prefix?"
    The compiler adds various prefixes depending on whether & how parameters are passed.
    See the "Segment Naming Conventions" section in the manual

    The error probably means that you've mismatched your function prototypes & definitions.

    What exactly is the error you get?
    What does it tell you if you look up the error in the help?

  • A function name has an underscore prepended if the function has any parameters. No parameters, no underscore. Goodness knows why...

  • A function name has an underscore prepended if the function has any parameters. No parameters, no underscore. Goodness knows why...

    This is incorrect.

    In the compiler manual, there is a section named "Segment Naming Conventions". In that section, is a sub-section named, "Program Objects".

    Under "Program Objects", there is a table that discusses the naming conventions for functions. A segment with an _ prefix indicates that arguments for that function are passed in registers.

    If you do not want your arguments to be passed in registers, use the NOREGPARMS directive.

    Jon