alphaone
Messages postés134Date d'inscriptionvendredi 2 mai 2003StatutMembreDernière intervention14 novembre 2009
-
1 mai 2008 à 22:41
SAKingdom
Messages postés3212Date d'inscriptionlundi 7 novembre 2005StatutMembreDernière intervention16 février 2009
-
1 mai 2008 à 23:34
Bonjour, j'ai un fichier d'en tête .h inclut partout ou il y as:
#ifndef INCLUDE_ENV_H
#define INCLUDE_ENV_H
//debug level, 0: no debug, 10 critical and internal error, 50 show main activity, 90 debug mode, more than 100 is useless.
#define DEBUG 100
Et il me dit que je redéfini la fonctiondebug_console_fonction():
CopyThread.o: In function `debug_console_fonction(int, QString)':
CopyThread.cpp:(.text+0x710): multiple definition of `debug_console_fonction(int, QString)'
AddFolderThread.o:AddFolderThread.cpp:(.text+0xf20): first defined here
Ewindow.o: In function `debug_console_fonction(int, QString)':
Ewindow.cpp:(.text+0x130): multiple definition of `debug_console_fonction(int, QString)'
AddFolderThread.o:AddFolderThread.cpp:(.text+0xf20): first defined here
FEwindow.o: In function `debug_console_fonction(int, QString)':
FEwindow.cpp:(.text+0xaa0): multiple definition of `debug_console_fonction(int, QString)'
AddFolderThread.o:AddFolderThread.cpp:(.text+0xf20): first defined here
main.o: In function `debug_console_fonction(int, QString)':
main.cpp:(.text+0x120): multiple definition of `debug_console_fonction(int, QString)'
AddFolderThread.o:AddFolderThread.cpp:(.text+0xf20): first defined here
Mwindow.o: In function `debug_console_fonction(int, QString)':
Mwindow.cpp:(.text+0x16c0): multiple definition of `debug_console_fonction(int, QString)'
AddFolderThread.o:AddFolderThread.cpp:(.text+0xf20): first defined here
SAKingdom
Messages postés3212Date d'inscriptionlundi 7 novembre 2005StatutMembreDernière intervention16 février 200915 1 mai 2008 à 23:34
Si tu veux utiliser printf dans 2 fichiers .c/.cpp, il faudra bien inclure stdio.h dans chacun d'eux. Même principe ici.
#ifndef ...
#define...
...
#endif
empêche seulement que le .h soit réinclus plusieurs fois dans un même fichier source (.c/.cpp).
SAKingdom
Messages postés3212Date d'inscriptionlundi 7 novembre 2005StatutMembreDernière intervention16 février 200915 1 mai 2008 à 22:49
Normal. Partout ou tu inclus ton header, il redéfinit ta fonction.
2 solutions:
soit tu déclare cette fonction dans un .c puis tu ne met que son prototype dans le header
soit tu déclare cette fonction en inline: