When creating multiple c files in keil, *** ERROR LXX appears

Publisher:乘风翻浪Latest update time:2015-09-29 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 called C files do not need the initialization process).
Keywords:keil Reference address:When creating multiple c files in keil, *** ERROR LXX appears

Previous article:Analyze and evaluate the advantages and disadvantages of Linux and WinCE from 10 aspects
Next article:Key debounce - pulse edge detection method

Recommended ReadingLatest update time:2024-11-16 14:59

Four basic data types of Keil uVision4 for 51 MCU
In the standard C language, there are six basic data types: 1. char: character type; 2. short = short int: short integer 3. int: integer 4. long = long int: long integer 5. float: single-precision floating point type 6. double: double-precision floating p
[Microcontroller]
Keil5 software simulation waveform and solution to unknown signal
When I was writing a report a few days ago, I accidentally needed to use the software simulation in Keil5 to see the output PWM waveform. After several attempts, I finally figured it out. The problem of unknown signal also appeared. 1. Setting steps for software simulation with Keil5 First, as shown in the figure
[Microcontroller]
Keil5 software simulation waveform and solution to unknown signal
51 MCU Study Notes 0 -- Programming Software Installation (Keil)
The previous article talked about simulation software, which is only for analog circuit simulation with or without a physical development board. However, the derogatory software is indeed indispensable, that is, Keil. I believe that many programming enthusiasts have come into contact with Keil software. Keil has 51 co
[Microcontroller]
51 MCU Study Notes 0 -- Programming Software Installation (Keil)
Keil C51 pointer summary
  A variable is a quantity whose value can change continuously during the execution of a program. To use a variable in a program, you must first use an identifier as the variable name and indicate the data type and storage mode used, so that the compiler system can allocate the corresponding storage space for the vari
[Microcontroller]
Keil C51 pointer summary
Proteus and Keil Cx51 microcontroller simulation (flowing light)
Proteus circuit diagram Keil Cx51 program: #include reg51.h sbit VD9=P0^0;  sbit VD10=P0^1;  sbit VD11=P0^2; sbit VD12=P0^3; sbit VD13=P0^4; sbit VD14=P0^5; sbit VD15=P0^6; sbit VD16=P0^7; sbit VD1=P1^0; sbit VD2=P1^1; sbit VD3=P1^2; sbit VD4=P1^3; sbit VD5=P1^4; sbit VD6=P1^5; sbit VD7=P1^6; sbit VD8=P
[Microcontroller]
Integrating Keil C51 Tools in Silicon IDE
Note: Silicon IDE and Keil software must be installed to compile or simulate the project. In this example, the software is installed in the default path. ·Silicon IDE installation:   Please go to the Silabs official website:  http://www.silabs.com/products/mcu/Pages/SoftwareDownloads.aspx?cm_sp= WebParts -_- MCUSuppor
[Microcontroller]
Integrating Keil C51 Tools in Silicon IDE
stm32 single-step debugging, *** error 65: access violation at 0x40023
Problem solved as title: When single-step debugging, it always runs in systeminit(), and full-speed execution does not work. The debugging error message is as follows *** error 65: access violation at 0x40023800 : no 'read' permission   The problem is caused by the MDK settings. In the Debug tab, there are two o
[Microcontroller]
Remapping of interrupt vector of stm32f030R8 APP program under keil environment
1. Theoretical basis:         Stm32f030R8 has 64KFlash + 8KSram        The positioning of the interrupt vector table of the Stm32f0 series MCU is a little different from that of other STM32 series, that is, the M0 series does not have the interrupt vector table relocation register like other M3/M4/M0+ series,
[Microcontroller]
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号