Bonjour,

Je cherche à faire une macro ou fonction inline de ce genre:


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
inline CString readID(int id){
  CString strFilter;
  strFilter.LoadString(id);
  return strFilter;
}
 
#define transT2(str) \
#ifdef str \
  readID(id) \
#else \
  _T("str")
L'idée est que:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
#define CHAINE "toto"
CString s1 = transT2(CHAINE); //renvoie "toto"
CString s2 = transT2(CHAINE_NON_DEFINIE); //renvoie "CHAINE_NON_DEFINIE"
Quelqu'un sait comment je pourrai faire ce genre de macro?
Idéalement je voudrais faire ça:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
#define TOTO "toto_modifie1"
#define TO_TO "toto_modifie2"
CString s1 = transT2("toto"); //renvoie "toto_modifie1" car TOTO est définie
CString s1 = transT2("to to"); //renvoie "toto_modifie2" car TO_TO est définie
CString s1 = transT2("toyota"); //renvoie "toyota" car la macro TOYOTA n'est pas définie
Je sait pas si c'est possible?

Merci d'avance