ARM Technical Support Knowledge Articles

UNRESOLVED EXTERNAL ERROR USING ASSEMBLER AND C

Applies to: C51 C Compiler

Answer


Information in this article applies to:


SYMPTOMS

Why do I get an Unresolved External Symbol error when I declare a C function prototype as taking a void parameter and not when I declare it using an unsigned char parameter? My function is defined in assembly code.

This causes an Unresolved External Symbol error:

unsigned char FOO(void);

This works:

unsigned char FOO(unsigned char);

In my assembly code:

A SEGMENT CODE
  PUBLIC _FOO
  RSEG A

_FOO:  ret
              END

CAUSE

In your assembly code you have started the function name with an underscore. This indicates that the parameters to the function are passed in registers. When you declare the protoype with no parameters it does not match the definition, hence the Unresolved External Symbol error.

RESOLUTION

If you do not wish to pass a parameter to the function then change the name in your assembly code to 'FOO', removing the underscore. The definition will then match up with the prototype.

SEE ALSO

Article last edited on: 2001-08-16 00:00:00

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential