How Linkers Resolve Multiply Defined Global Symbols in C
问题 My Textbook says that: "Functions and initialized global variables get strong symbols. Uninitialized global variables get weak symbols.Given a strong symbol and multiple weak symbols, choose the strong symbol" So I create two files to see: file1.c: int number; int main(int argc, char *argv[]) { printf("%d",number); return 0; } file2.c (just one line): int number = 2018; and I ran gcc -Wall -o program file1.c file2.c and the output is 0, which I can understand before I study linker ('number'