J'ai créé deux fichiers:En utilisant extern en C ne fonctionne pas comme prévu
tunables.h
#ifndef TUNABLES_H
#define TUNABLES_H
void tunables_load_conservative();
void tunables_load_aggressive();
extern int timer_x;
#endif /*TUNABLES_H */
et tunables.c
#include "tunables.h"
int timer_x;
void tunables_load_conservative(){
timer_x = 3;
}
void tunables_load_aggressive(){
timer_x = 1;
}
Tous les autres fichiers de mon Le projet comprend "tunables.h". Quand je charge le projet à la fois A.c et appelle av. J.-C. tunables_load_conservative mais si, après un certain temps, je l'appelle dans le fichier A.c tunables_load_aggressive() dans le fichier b.c le timer_x reste 3. Pourquoi?
Ceci est mon Makefile:
INCLUDE=`pwd`/include
GCCFLAGS= -ansi -O3 -pedantic -Wall -Wunused -I${INCLUDE} -DDEBUG
GCCOTHERFLAGS= -ggdb -pg
all: A B
A: A.o tunables.o
gcc -o A ${GCCFLAGS} ${GCCOTHERFLAGS} tunables.o
B: B.o tunables.o
gcc -o LBfixed ${GCCFLAGS} ${GCCOTHERFLAGS} tunables.o
A.o: A.c
gcc -c ${GCCFLAGS} ${GCCOTHERFLAGS} A.c
B.o: B.c
gcc -c ${GCCFLAGS} ${GCCOTHERFLAGS} B.c
tunables.o: tunables.c
gcc -c ${GCCFLAGS} ${GCCOTHERFLAGS} tunables.c
clean:
rm -rf *.o A B
Veuillez marquer correctement vos questions relatives à la fabrication (avec la balise [make]). Plus d'infos: http://meta.stackexchange.com/questions/24030/why-do-they-specify-makefile-tag-instead-of-make/26567#26567 –