70,020
社区成员




int test2(void);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "file2.h"
char dummy1[0];
char buf[100];
int test1(void)
{
printf("dummy1: %p\n", dummy1);
printf("test1: buf (%p): %s\n", buf, buf);
return 0;
}
int main(void)
{
fgets(buf, 100, stdin);
test1();
test2();
fflush(stdin);
getchar();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "file2.h"
char dummy2[0];
char buf[100];
int test2(void)
{
printf("dummy2: %p\n", dummy2);
printf("test2: buf (%p): %s\n", buf, buf);
return 0;
}
gcc -g -Wall -c file1.c
gcc -g -Wall -c file2.c
gcc -o f1-f2 file1.o file2.o
gcc -o f2-f1 file2.o file1.o
root@debian:/tmp# ./f1-f2
123
dummy1: 0x80497a0
test1: buf (0x80497a0): 123
dummy2: 0x8049804
test2: buf (0x80497a0): 123
root@debian:/tmp# ./f2-f1
456
dummy1: 0x8049804
test1: buf (0x80497a0): 456
dummy2: 0x80497a0
test2: buf (0x80497a0): 456
root@debian:/tmp# gcc --version
gcc (Debian 4.4.5-8) 4.4.5