This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Optimization and unused variables
- From: Eckhard Jokisch <e dot jokisch at u-code dot de>
- To: gcc at gcc dot gnu dot org
- Date: Sat, 6 Sep 2003 14:16:49 +0200
- Subject: Optimization and unused variables
- Reply-to: e dot jokisch at u-code dot de
Hello,
I have some questions concerning the optimization with gcc.
a small programm with three files:
global.h:
#ifndef GLOBAL_H
#define GLOBAL_H
typedef struct structure1
{
int a;
int b;
} TSt1;
TSt1 st;
#endif
------------------------------
main.c:
#include "global.h"
int d; //never used
extern int function1(TSt1 * st);
int main( int arc, char** argv)
{
int c;
st.a =1;
c=function1(&st);
return c;
}
-------------------------------------
function.c:
#include "global.h"
int function1(TSt1 * p)
{
p->a=0;
return p->a;
}
This is just a testcase. If I compile it with
# gcc -Wall -Wunused -o test main.c function.c
I get no warning about the unused structure variable "int b"
GCC is:
gcc version 3.2.3
Is this expected behaviour and (as I think it is) is there a way to get
warnings about unused members/variables? Or a way to "optimze" them away?
I need this to find out possible chances to squeeze memory usage in an
embedded unit.
Greets
Eckhard