Hi,
I am writing program, which uses some functions located in sepereted object files. It imports headers of these functions from a header file. They are declared according to this pattern:
Source of the functions is located, as I said befor, in sepereted source files, which import some header files with structures if it is needed. I have already writen one of them. I have noticed one huge error. It can't be found by compiler, because it isn't gramatical error.Code:export type name(data);
Befor I describe the problem let's see the code
- code of the function
Code:short int create(gr *start, gr *aktualna_gr, const char **argv, const int argc) { ... wsk = (gr *)malloc(...); ... start = wsk; ... return(0); }- reference from the main()
Code:x = create(root, current_gr, (const char **)argv, (const int)argc);- additional information
Code:typedef struct grupa gr; //it is from header file with declaration of struct grupa gr* root = NULL; //definition at main()
Now my problem:
In create() variable start at the begining is = (nil), after commanduntil end of the function start is equal variable wsk. However outside definition of start() exactly after the reference in main() root which is the pointer that should take over the value of variable start from the definition is still equal (nil).Code:start = wsk;
I have writen function similiar to crate() befor, but then I imported code of it usingand it worked properly .Code:#import "source.c"
I compile the program using makefile. It compiles source files to objects and then doI use gcc (GCC) 3.3.5 (Debian 1:3.3.5-13), GNU ld version 2.15 and GNU Make 3.80.gcc -o system main.o create.o ...some other objects
What is wrong? I only expect the function to save new pointer in variable root. I'm totally confused and sad and it's all what I'd like to tell.