Keil™, An ARM® Company

Technical Support

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

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Tuesday, July 19, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure