Keil Logo

A251: Failure to Handle Sbit and Inline Assembly


Information in this article applies to:

  • C166 Version 3.12
  • C251 Version 2.14
  • C51 Version 5.50

SYMPTOMS

When generating or using two or more SRC files in a project, and both files use the same sbit definition, the linker generates a "MULTIPLE PUBLIC DEFINITIONS ERROR".

CAUSE

The Compiler has no idea what's going on in other source files, and so when it encounters the sbit definition, in converting it to assembly, generates a PUBLIC definition of it for the assembler. If it didn't default to this, you'd be forced to go to considerable lengths to declare a global variable in a module with inline assembly.

RESOLUTION

Declaring the sbit in question as an extern in the non-main C files will prevent the error and still provide linkage to the primary (sfr) declaration.

You could handle this on a larger scale by having a separate header with externs of the sfrs for use in C files other than main, which will permit you to use them irrespective of the asm question, and without the attendant errors.

Last Reviewed: Wednesday, September 21, 2016


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.