KEILC51 compilation problem ERROR L104

Publisher:RainbowPromiseLatest update time:2016-09-14 Source: eefocusKeywords:KEIL Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
There are many places in C/C++ language where extern is used. However, if you don't really understand its meaning, it will cause great trouble to programming. In order to help you avoid detours, we will explain it in detail.
      For smaller programs, there is usually only one C file and one header file. We usually define global variables directly in the C file, and add the int i definition before the program. If you want to define it in the header file, there are two ways: use extern to declare: extern int i; This sentence only declares the variable i. Int i must be added before the C file program to define it. extern int i=0; This sentence does both declaration and definition.
    For larger programs, there are many C files and header files. At this time, global variables must be declared in the header file (no initialization is required), and then defined in a C file (the initialized ones must be initialized). If defined in the header file, there will be a duplicate definition error when compiling. If it is only declared in the header file, there will be a warning that there is no definition.
   *** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
       SYMBOL: K
       MODULE: 222.obj (222)
The above error occurs because the variable k is defined repeatedly. Add extern before the variable definition in your header file (it is just a variable declaration without initialization), and then define it before a program that calls a C file of the variable (note that the first C file called is responsible for initializing the variable, and other C files that call do not need the initialization process)
Keywords:KEIL Reference address:KEILC51 compilation problem ERROR L104

Previous article:Combination lock course design
Next article:12864 LCD display pictures

Recommended ReadingLatest update time:2024-11-16 16:37

CS5532 C51 Driver
//The program for CS5532-ASZ //This is a 24bit ADC and PGIA //Made by OurWay and 2006/03/21 //#include reg51.h //#include intrins.h //Define according to actual situation //sbit SDI5532 = P2^1; //sbit SDO5532 = P2^2; //sbit CLK5532 = P2^3; //sbit CS5532 = P2^0; //sbit ACC7 =
[Microcontroller]
OK2440 KEIL bare metal debugging experience
This is my first time to use ARM bare metal debugging. I’m going to record this here for reference by people who encounter the same problem. First, you need to download the corresponding Samsung keil library, which can be found on the legend download page of the keil official website. It is an .exe file and can be i
[Microcontroller]
Keil C51 program crashes when using serial port
When using the serial port of the STC51 microcontroller, sometimes a very strange situation occurs, that is, the program runs dead as soon as it enters. The initialization code is as follows: void UsartConfiguration(unsigned int bps) { SCON = 0X50; //Set to working mode 1 10-bit asynchronous receiver and transmitte
[Microcontroller]
Microcontroller C language tutorial: C51 expression statement and simulator
We have learned most of the basic syntax in the previous section. The syntax of the various basic statements to be learned below can be said to be the soul of the program. In the examples in the previous courses, we have also briefly understood the use of some statements, and we can see that C language is a structur
[Microcontroller]
Microcontroller C language tutorial: C51 expression statement and simulator
51 MCU Keil C Delay Program
When using a single-chip microcomputer, you often encounter situations where a short delay is required. The required delay time is very short, usually tens to hundreds of microseconds (us). Sometimes very high precision is also required. For example, when using a single-chip microcomputer to drive a DS18B20, the allow
[Microcontroller]
CXSTM8 parameterless function note
When keil has no parameter function, like, int fun() { int i = 0; return i; } There is no problem with compilation, but in ST's CXSTM8 it needs to be written as int fun(void) { int i = 0; return i; } Can be compiled. Otherwise it will appear #error cpstm8 xxxxxxxxxxxxxxxxx missing prototype
[Microcontroller]
c51: Function
/* char cabs(char val); // calculate the absolute value of val    int abs(int val); long labs(long val); float fabs(float val); float sqrt(float val);    float exp(float val); float log(float val); float log10(floatextefn floatl0510〔float val); float sin(flaot val); float cos(flaot val); float tan(flaot val)
[Microcontroller]
Serial communication between C51 and atmega64 and PROTEUS simulation design
script src="/jf/jf-arcMain-1.js" type=text/javascript /script script type=text/javascript /script script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type=text/javascript /script script src="http://pagead2.googlesyndication.com/pagead/js/r20110914/r20110914/show_ads_impl.js" /script
[Microcontroller]
Serial communication between C51 and atmega64 and PROTEUS simulation design
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号