Bonjour tout le monde,

j'essaye de trouver une solution au problème de macro C ci-dessous.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
#define    INDEX_1   1
#define    INDEX_2   2
 
unsigned char   LBa_MonBuffer1[4] = {1,2,3,4};
unsigned char   LBa_MonBuffer2[4] = {4,3,2,1};
 
unsigned char LBa_output[4] = {0};
 
#define   MA_SUPER_MACRO( source, index, destination ) \
{ \
    memset(destination,0,sizeof(destination) ); \
    memcpy(destination,source ## index , sizeof(destination) ); \
}\
/** Ce qui suit est fonctionnel **/
MA_SUPER_MACRO( LBa_MonBuffer, 1, LBa_output ); /** Resultat : LBa_output= 1,2,3 et 4 **/
MA_SUPER_MACRO( LBa_MonBuffer, 2, LBa_output ); /** Resultat : LBa_output = 4,3,2 et 1 **/
 
/** Ce qui suit est NON fonctionnel **/
MA_SUPER_MACRO( LBa_MonBuffer, INDEX_1, LBa_output ); /** Resultat attendu : LBa_output= 1,2,3 et 4 **/
Quelqu'un pourrait me dire si ce que j'essaye de faire est possible ?

Je vous remercie tous !

Arnaud