We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I haven't received an answer that fixed my problem, so here is another example.
I have a simple printf statement that causes a L103 error. No variables declared. Includes "stdio.h" and links in C51FPL.LIB. Others LIBs don't seem to link correctly either. Code compiles fine. Anyone know what the linking problem could be?
#include "stdio.h"
main() { printf("12345"); }
BL51 BANKED LINKER/LOCATER V5.12 COPYRIGHT KEIL ELEKTRONIK GmbH 1987 - 2004
*** ERROR L103: EXTERNAL ATTRIBUT DO NOT MATCH PUBLIC SYMBOL: ?_PRINTF?BYTE MODULE: C51FPL.LIB (PRINTF)
Program Size: data=15.1 xdata=48 code=2562 LINK/LOCATE RUN COMPLETE. 0 WARNING(S), 1 ERROR(S)
Do you have ANSI integer promotion enabled?
The format string in your printf is "%d", which is to say an integer, which means 2 bytes for C51. However, you pass it "x", which is declared as char -- 1 byte. This means the actual data passed to printf does not match what the format tells printf() to process, and you will not get the expected results.
Keil introduced a 'b' modifier for 1-byte integers, e.g. "%bd".
The alternative is to enable ANSI integer promotion, which means ALL single-byte parameters to ALL functions will be passed as two-byte integers instead of one byte. This usually means a fair amount of extra, unneeded code.
DOH....That was it. Should have figured that out myself.