read

作者: 我的小诗 | 来源:发表于2020-12-19 12:55 被阅读0次
int CopyStrValue(char **dst, const char *src, int length) {
    if (length <= 0) {
        return 0;
    }
    *dst = malloc(length + 1);
    if (*dst == NULL) {
        return -1;
    }
    StrMemSet(*dst, 0, length);
    strncat(*dst, src, length);
    return 0;
}
typedef enum {
    EN_IOTA_EVENT_ADD_SUB_DEVICE_NOTIFY = 0,
    EN_IOTA_EVENT_DELETE_SUB_DEVICE_NOTIFY = 1,
    EN_IOTA_EVENT_VERSION_QUERY = 2,
    EN_IOTA_EVENT_FIRMWARE_UPGRADE = 3,
    EN_IOTA_EVENT_SOFTWARE_UPGRADE = 4,
    EN_IOTA_EVENT_GET_TIME_SYNC_RESPONSE = 5,
//  EN_IOTA_EVENT_GET_UPLOAD_URL_RESPONSE = 6,
//  EN_IOTA_EVENT_GET_DOWNLOAD_URL_RESPONSE = 7,
    EN_IOTA_EVENT_TYPE_ERROR = -1
} EN_IOTA_EVENT_TYPE;

宏定义和枚举的使用

struct CPoint SymmetricAxis(struct CPoint p, enum SymmetricStyle style)   // 返回对称点
{
    struct CPoint p1;
    switch(style)
    {
    case axisx:
        p1.x=p.x;
        p1.y=-p.y;
        break;
    case axisy:
        p1.x=-p.x;
        p1.y=p.y;
        break;
    case point:
        p1.x=-p.x;
        p1.y=-p.y;
    }
    return p1;
}

宏定义的使用场景主要是 灵活配置参数 条件编译

#define MacroLog(...)\
{\
FILE* file;\
fopen_s(&file,"./a.txt","a");\
if (file != nullptr)\
{\
fprintf(file, "%s: Line %d:\t", __FILE__, __LINE__);\
fprintf(file, __VA_ARGS__);\
fprintf(file, "\n");\
}\
fclose(file);\
}

https://blog.csdn.net/imgosty/article/details/81901183

相关文章

网友评论

      本文标题:read

      本文链接:https://www.haomeiwen.com/subject/pfzqnktx.html