J'ai ce code qui me retourne un mechant message d'erreur ᅵ la compilation :
/* --------------------- CODE ------------------ */
#ifndef CONVERT_TOOLS_H_INCLUDED
#define CONVERT_TOOLS_H_INCLUDED
#include <limits.h>
#include <ctime>
#include <string.h>
#include <base/Exception.hpp>
namespace base
{
/***
* Convert a DTime to CTime
***/
time_t toTime_t (long long DTime);
/***
* Swap values of a char array
***/
void swapChars(char* bytes,size_t length);
/***
* Invert endianness of dataIn and set it in dataOut
***/
template<typename T>
void swapBytes(T& dataIn,T& dataOut);
}
#include "base/convert_tools.tpl"
#endif // CONVERTTOOLS_H_INCLUDED
/* -------------------FIN CODE------------------ */
Le fichier "base/convert_tools.tpl" contient les dᅵfinitions de ces
prototypes.
Comme j'ai des templates, c'est le header qui inclut les dᅵfinitions et
pas le contraire.
L'erreur qui m'est retournᅵ :
src/fx/get/duk/Duk.o: In function `base::toTime_t(long long)':
/media/sda3/home/tsalm/dev/Mine/./src/base/convert_tools.tpl:17: multiple
definition of `base::toTime_t(long long)'
/tmp/ccQSRVzJ.o:/media/sda3/home/tsalm/dev/Mine/./src/base/convert_tools.tpl:17:
first defined here
src/fx/getweb/duk/Duk.o: In function `base::swapChars(char*, unsigned
int)':
/media/sda3/home/tsalm/dev/Mine/./src/base/convert_tools.tpl:31: multiple
definition of `base::swapChars(char*, unsigned int)'
/tmp/ccQSRVzJ.o:/media/sda3/home/tsalm/dev/Mine/./src/base/convert_tools.tpl:31:
first defined here
src/fx/convert/duk/duk_tools.o: In function `base::swapChars(char*,
unsigned int)':
/media/sda3/home/tsalm/dev/Mine/./src/base/convert_tools.tpl:31: multiple
definition of `base::swapChars(char*, unsigned int)'
/tmp/ccQSRVzJ.o:/media/sda3/home/tsalm/dev/Mine/./src/base/convert_tools.tpl:31:
first defined here
src/fx/convert/duk/duk_tools.o: In function `base::toTime_t(long long)':
/media/sda3/home/tsalm/dev/Mine/./src/base/convert_tools.tpl:17: multiple
definition of `base::toTime_t(long long)'
/tmp/ccQSRVzJ.o:/media/sda3/home/tsalm/dev/Mine/./src/base/convert_tools.tpl:17:
first defined here
collect2: ld returned 1 exit status
make: *** [tests/fx/test4] Error 1
Comprends pas pourquoi !?
D'avance merci pour votre aide ᅵ combien ᅵclairante :-)
-TSalm
>/media/sda3/home/tsalm/dev/Mine/./src/base/convert_tools.tpl:17: multiple
>definition of `base::toTime_t(long long)'
Cette fonction n'est pas un template. Tu ne dois donc en inclure la
d�finition que dans un seul module (.cpp).
Plus pr�cis�ment, sa d�finition doit se trouver dans un fichier .cpp,
pas dans un fichier .tpl.
Exact! Comme toujours.
Merci Fabien.