IAR ERROR---[Li006]

Source: Internet
Author: User

Porting code today encountered a very wonderful problem, recorded as follows:

ERROR[LI006]: Duplicate definitions for "UART3"; In "E:\IAR_1768PRO_PCB799\DEBUG\OBJ\UART3_INIT.O", and "E:\IAR_1768PRO_PCB799\DEBUG\OBJ\UMODEMG600.O"

Repeating defined variables Uart3

However, the umodemg600.c file does not Uart3 this variable, only uart3.h this header file, the problem appears in this file.

Uart3 the definition of this variable is placed in the uart3.h, and uart3.h in uart3.c and UMODEMG600.C have # include, Uart3.h also did not do conditional compilation, resulting in uart3.h repeated compilation, variable repetition definition.

=================== problem description Complete, a personal point of view ======================

My personal practice is that the variables/functions are defined in the *.c file, the variables/functions are declared in the *.h file, and the *.h file is compiled with the condition, and the duplicate inclusions are placed in the following format:

User.c

1 //user.c File2 3#include <stdio.h>4#include <string.h>5#include"User.h"6 7SignedCharG_a =0;8UnsignedCharG_b =0;9SignedintG_c =0;Ten   One voidFUN1 (void) A { -     //Do something - } the  - voidFun2 (void) - { -     //Do something +}

User.h

#ifndef _user_h_ #define _user_h_externchar  g_a; extern Char G_b; extern int G_c; void fun1 (void); void fun2 (void); #endif

IAR ERROR---[Li006]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.