This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Optimization and unused variables


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]