I am searching for a solution where GCC (Arm-Embedded Version) is able to tell me if a variable is not existing at all, when allocated as part of a struct.
The current examples do not warn at all, which i would like to change.
Example 1:
Example 1 has 3 variables from a sturct: var1: assigned but never referenced elsewhere, therefore i want to remove it var2: not even assigned, makes no sense to waste ram here, remove it return: assigned and referenced, everything ok.
therefore i would like to get 2 warnings here.
struct mydummy_t
{
bool var1;
bool var2;
int return;
};
static mydummy_t dummy;
int main()
{
dummy.var1 = true;
dummy.return = 15;
return dummy.return;
}
Example 2:
same as example one but now we have a class constructor which initially addresses every variable, but again, not all of them are referenced.
struct mydummy_t
{
mydummy_t() : var1(false), var2(true), return(-1) {}
bool var1;
bool var2;
int return;
};
static mydummy_t dummy;
int main()
{
dummy.var1 = true;
dummy.return = 15;
return dummy.return;
}