my test code is below:
main1.c:
#include <stdio.h>
extern struct tt ;
int main()
{
struct tt y;
y.a=255;
y.b=0;
printf("tt->a=%#x ,tt->b=%#x \n",y.a,y.b);
}
main2.c:
#include<stdio.h>
struct tt
{
int a;
int b;
};
makefile:
main: main1.o
gcc -o main main1.o
main1.o: main2.c main1.c
but the compiler reports:
cc -c -o main1.o main1.c
main1.c:2: warning: useless storage class specifier in empty declaration
main1.c: In function ‘main’:
main1.c:5: error: storage size of ‘y’ isn’t known
make: *** [main1.o] Error 1
how do I write code to in a .c file use the struct defined in another .c file ???
thx for your help!