C
Control Freq
Hi,
I have inheritted a large project, and its quite old, with quite a lot
of work over the last few years.
I see that a struct is defined a the top of two files, unit1.c and
unit2.c .
But, the struct has the same name, but the struct in unit2.c has more
elements.
A function in unit2.c takes a pointer to the struct as an arg, and the
function is called from unit1.c .
Now, I think that this is a bug, because the struct is in two places,
and of two different sizes, and when the function is called, the
program crashes.
But, why didn't the compiler warn me about this problem? I presume
it's a linker issue rather than a compiler issue. But, is there any
way of getting the compiler to throw an error when this happens?
There are many code files to check through, it's going to take ages to
check them all!
Help appreciated.
Nick
I have inheritted a large project, and its quite old, with quite a lot
of work over the last few years.
I see that a struct is defined a the top of two files, unit1.c and
unit2.c .
But, the struct has the same name, but the struct in unit2.c has more
elements.
A function in unit2.c takes a pointer to the struct as an arg, and the
function is called from unit1.c .
Now, I think that this is a bug, because the struct is in two places,
and of two different sizes, and when the function is called, the
program crashes.
But, why didn't the compiler warn me about this problem? I presume
it's a linker issue rather than a compiler issue. But, is there any
way of getting the compiler to throw an error when this happens?
There are many code files to check through, it's going to take ages to
check them all!
Help appreciated.
Nick