|
visible on different files?
Ok guys, so I have 2 files, one named "main2.c" and the other named "something.c", very simple ones.
Here is main2.c:
#include <stdio.h>
typedef struct
{
int i;
int j;
}MINE;
void something (MINE var);
int main()
{
MINE p = {10, 20};
something(p);
return 0;
}
Here is "something.c":
#include <stdio.h>
void something (MINE var)
{
printf("value: %d\n", var.j);
}
When I type: gcc main2.c something.c -o main2
./main2
I get this: something.c:5: error: expected ')' before 'var'
WHY ON EARTH DOESN'T THIS WORK!?
The structure is declared outside of any function, so it goes to data segment, right? It is available inside the function something() too, tough its in another file! Right? But when I put the funcion void something (MINE var) on "main2.c" and compile it without "something.c" it works just fine, printing the value 20!
Last edited by DanielKs; 01-02-2009 at 04:15 PM.
|