If I declare and never use variable then gcc will give me a warning.
But if I have a struct with several members and some of those are not used, gcc will not warn about it...
Is there an option (or another method) to check these?
(Of course I can manually delete some entries and try to compile again, but I am looking for this kind of approach).
Thanks
No GCC won't warn about this. Mostly because in the majority case whether or not a member is used can't be determined. A good portion of struct
are defined in a header file. This can be used by not just your application but by any other application referencing your .lib or using the same header file. Hence just because the current piece of code being compiled doesn't use the member it doesn't mean that the member is not used by some other piece of code.
Local variables are different. Whether or not they are used easily determined by compiling only the function in question. Hence GCC, and many other compilers, give a warning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With