Hi All.
I have a structure defined in a header file called data.h
I am including data.h in myfile.c
in the structure, I have part of the variables blocked off with
#ifndef TEST
int x;
#endif
and in myfile.c i have
#ifdef TEST
localx++;
#else
mystruct.x++; //<-compiler complains on this line when compiling
#endif
When I try to compile with -DTEST I get a compiler complaining that mystruct type does not containing a field called x. What is up with this?
edit..adding this. I dont have a C compiler handy, so here is what I just typed up: in data.h
typdef struct {
#ifndef TEST
int x;
#endif
int y;
} coords;
in myfile.c
#include "data.h"
static coords coord1;
int localx;
int main( )
{
#ifdef TEST
localx = 1;
#else
coord1.x = 1;
#endif
coord1.y = 2;
printf("%i\n", coord1.x);
printf("%i\n", coord1.y);
printf("%i\n", localx);
return 0;
}
This compiles when I type "cc myfile.c" but not with "cc myfile.c -DTEST" I am using the MIPSPro C compiler referenced here: http://www.sgi.com/products/software/irix/tools/c.html