Originally Posted by
sniper83
The two messages is alike and thats right, i only posted the receiveMsgSpeechRecognition-method in file: speechRecognition.c.. Just outcomment the other one..
..... DAMN ME....... The most obvious thing just happend.. The definition in the c-file is good enough, but the declaretion in the header speechRecognition.h have a return-type of int... I changed it when i reconstructed the code in the c-file..
But It's global variables that should be avaliable everywhere, in all the files..? It should be possible to change them from all c-files... Theres an excact reason for that.. How should I do it else..?
Let's say you have a project with 2 source files (example1.c and example2.c) and you need to have globals that can be used/accessed in both source files. You put the instances/declarations of the globals in one of the files and then have a header (example.h) with all those variables but declared with extern as well.
example.h
Code:
#ifndef EXAMPLE_H
#define EXAMPLE_H
// These externs represent some globals in example1.c
extern int global_ex1_1;
extern int global_ex1_2;
// These externs represent some globals in example2.c
extern int global_ex2_1;
extern int global_ex2_2;
#endif
example1.c
Code:
// By including example.h, we can also access the globals declared in example2.c
#include "example.h"
int global_ex1_1;
int global_ex1_2;
example2.c
Code:
// By including example.h, we can also access the globals declared in example1.c
#include "example.h"
int global_ex2_1;
int global_ex2_2;
You have it backwards currently, many of your extern'd variables are in the source file while the instances themselves are in the header file global.h. If you were to ever #include global.h (as it stands now) in two different source files then you'd get tons of errors when linking your project because of multiple definitions of the same variable name.