Use occasion: Splicing two macros, one is the incoming macro. But the incoming macros will not be replaced, but it will be awkward to take them up. After a variety of attempts, incredibly became, hereby record sharing, convenient for everyone to learn.
Char a_param=0;
Char b_pramm=0; Add a macro definition
#define OBJECT A
#define DEFINE_ (X) x# #_param//Once defined
#define DEFINE (x) define_ (x)//re-defined
#define PARAM define (OBJECT) void Fun ()
{
Define_ (OBJECT) = 100; This operation is rejected, it is the direct stitching is not replaced
DEFINE (OBJECT) = 100; This operation is God, first replace and then splicing, we just made two definitions, solve all the trouble
param=100;//this is okay.
}
That ultimately is not to achieve your goal, the essence of the principle is probably the replacement and stitching sequence, I did not study carefully.
Here is a use of my occasion.
#define STEP_TIMX 4//TIM4
#define STEP_CHX 2//CH2
#define SET_STEP42_PPS_1 (num,x) tim# #NUM->psc= ((X))
#define SET_STEP42_PPS_2 (num,x) set_step42_pps_1 (num,x)
#define SET_STEP42_PPS (X) set_step42_pps_2 (step_timx,x)
The ultimate goal is to achieve tim4->psc=x, my goal is to achieve