search for: arcg

Displaying 2 results from an estimated 2 matches for "arcg".

Did you mean: arc
2009 Mar 07
0
[LLVMdev] global question
...#39;t think you can attach an initializer to an extern except at the > point where the variable is defined. But since x is defined here, > there > would then be two definitions of x, a link-time error. > FWIW -------- main.c ---------- #include <stdio.h> int x; int main(int arcg, char **argv) { fprintf(stderr, "x is: %d\n", x); return 0; } ---------- init.c --------- extern int x; __attribute__((constructor)) static void __initialize() { x = 12; } [MacBook:~/Desktop]% gcc -c init.c [MacBook:~/Desktop]% gcc -c main.c [MacBook:~/Desktop]% gcc -o test init.o...
2009 Mar 07
3
[LLVMdev] global question
> Please correct me if I'm wrong, but how can the compiler know, that x is not > initialized in another file which defines x as extern? It can only be > sure, when x is declared static. I don't think you can attach an initializer to an extern except at the point where the variable is defined. But since x is defined here, there would then be two definitions of x, a link-time