关于c语言宏定义与结构体的问题

2019-07-20 21:44发布

typedef struct RampGen_t                                                                //定义结构体
{
        int32_t count;
        int32_t XSCALE;
        float out;
        void (*Init)(struct RampGen_t *ramp, int32_t XSCALE);
        float (*Calc)(struct RampGen_t *ramp);
        void (*SetCounter)(struct RampGen_t *ramp, int32_t count);
        void (*ResetCounter)(struct RampGen_t *ramp);
        void (*SetScale)(struct RampGen_t *ramp, int32_t scale);
        uint8_t (*IsOverflow)(struct RampGen_t *ramp);
       
}RampGen_t;
#define RAMP_GEN_DAFAULT                                                        //宏定义结构体变量?可以嘛?
{
                                                        .count = 0,
                                                        .XSCALE = 0,
                                                        .out = 0,
                                                        .Init = &RampInit,
                                                        .Calc = &RampCalc,
                                                        .SetCounter = &RampSetCounter,
                                                        .ResetCounter = &RampResetCounter,
                                                        .SetScale = &RampSetScale,
                                                        .IsOverflow = &RampIsOverflow,
                                                }

RampGen_t LRSpeedRamp = RAMP_GEN_DAFAULT;                            //定义结构体变量,然后把宏定义的值赋到结构体变量中
这个程序是我看别人程序看来得,请问c语言编译有问题吗?

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
1条回答
1269784324
2019-07-20 23:56
#define RAMP_GEN_DAFAULT                                                      
{
                                                         0,
                                                         0,
                                                         0,
                                                        &RampInit,
                                                        &RampCalc,
                                                        &RampSetCounter,
                                                        &RampResetCounter,
                                                        &RampSetScale,
                                                        &RampIsOverflow,
                                                }
这样的可以,你这样不清楚,帮顶

一周热门 更多>