Keil Logo

BL51: Error 118 (Erroneous Reference to External Variables)


Information in this article applies to:

  • C51 All Versions

QUESTION

The following C file (C:\MYCODE\J1.C)...

/*------------------------------------------------------------/*
extern long Junk;
int junk;

void main (void)
{

for (junk = 0; junk < 100; junk++)
  {
  Junk = 1000L * junk;
  }

}
/*------------------------------------------------------------/*

generates the following error when compiled and linked with the Keil 8051 tools:

*** ERROR 118: REFERENCE MADE TO ERRONEOUS EXTERNAL
    SYMBOL:  JUNK
    MODULE:  C:\MYCODE\J1.OBJ (J1)
    ADDRESS: 0020H

What is wrong?

ANSWER

Your program is technically correct. The problem lies in the object module format of the object files created by the Keil C Compiler.

The object files are created according to the OMF-51 object module format specified by Intel. This object module format does not allow lowercase variable names. Therefore, all public variables are treated as uppercase. When you create 2 public symbols with the same name but with different cases, the linker complained about ERRONEOUS EXTERNALS.

Change the name of one of the variables to avoid this problem.

MORE INFORMATION


Last Reviewed: Thursday, February 25, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.