I have looked at several examples here and I am still coming up empty with this. I have an extern int *sharedarray[]
in my header file. I define it as int *sharedarray[]
in my three .c
files. In my first .c
file I allocate how much memory it is going to need with malloc
. It must be dynamically allocated at that point. After that I set the values. For the purpose of testing I am just incrementing them by 1. Then, another .c
file, I go to print
the array. What was 0,1,2,3 has become 0,3,2,2 ?
I am at a total loss for what is going on here. I am sure that this is something simple, but it has been blocking me for over 4 hours now. Does anyone know what I should do?
header.h
extern int *array[];
file1.c
int *array[];
file2.c
int *array[];
My make files uses:
file1: $(proxy_obj) file2.o, header.o