I have 3 files
//--------------reg_des.h---------------
struct reg
{
unsigned int i : 4;
unsigned int j : 4;
};
extern struct reg;
//--------------reg_des.c---------------
struct reg xyz_reg = {.i = 2,.j = 1};
//--------------main.c---------------
#include "reg_des.c"
void display_onmodule(struct reg xyz_reg_1)
int main()
{
display_onmodule(xyz_reg);
}
void display_onmodule(struct reg xyz_reg_1)
{
.....
}
Here I have declared a struct in a header file and initialize variable of struct type in another source file. Actually I want to know is it right way to declare a struct which may be used by multiple source files?