I define a variable
unsigned char c in a file A.h and include it in A.c and another file B.c in which the variable is being used. Then I face a linker error of multiple public definitions. PS: The variable is declared once for sure. The usual way of making header files is used. #ifndef etc. Can anyone help me remove this error? I'll be very grateful.
in a file A.h and include it in A.c and another file B.c in which the variable is being used. Then I face a linker error of multiple public definitions. PS: The variable is declared once for sure. The usual way of making header files is used. #ifndef etc. Can anyone help me remove this error? I'll be very grateful.
#ifndef etc. Can anyone help me remove this error? I'll be very grateful.
etc. Can anyone help me remove this error? I'll be very grateful.
"I define a variable unsigned char c in a file A.h and include it in A.c and another file B.c in which the variable is being used." Thus both A.c and B.c contain a definition of this variable, don't they? So you will obviously get a "multiple definitions" error! Instead you should define the variable in just one of your .c files, and provide and extern declaration in the header file.
View all questions in Keil forum