This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ERROR L104: MULTIPLE PUBLIC DEFINITIONS

I am two C files in a project.
1. main.c
2. rtc.c and third one is header file for both in which all prototypes are defined.

I want to use a bit variables named aon and aoff in both files.
Now three condition arises

1. i declare extern bit aon,aoff; in header file but it gives error

//ERROR L104: MULTIPLE PUBLIC DEFINITIONSERROR L104: MULTIPLE PUBLIC DEFINITIONSERROR L104: MULTIPLE PUBLIC DEFINITIONSextern bit aon=0,aoff=0;

2. i declare extern bit aon,aoff; in onlyin main file but it gives error

aon and aoff not declared in rtc; and vice versa

3. i declare in both c files than again i gives error

//ERROR L104: MULTIPLE PUBLIC DEFINITIONSERROR L104: MULTIPLE PUBLIC DEFINITIONSERROR L104: MULTIPLE PUBLIC DEFINITIONSextern bit aon=0,aoff=0;

Why?

Parents
  • Hello!.
    Maybe this help to you.
    Define the variables as follows in main.h or main.c

    unsigned long var1;
    unsigned long var2;
    


    in othe header file where you need to define this variable define as follows

    extern unsigned long var1;
    extern unsigned long var2;
    

    Sorry for my english.:)
    With best regards Artem Gusev.

Reply
  • Hello!.
    Maybe this help to you.
    Define the variables as follows in main.h or main.c

    unsigned long var1;
    unsigned long var2;
    


    in othe header file where you need to define this variable define as follows

    extern unsigned long var1;
    extern unsigned long var2;
    

    Sorry for my english.:)
    With best regards Artem Gusev.

Children