透明水晶 2024-04-10 18:14 采纳率: 96.8%
浏览 4
已结题

开发笔记-20240410:编译报错

开发笔记-20240410:编译报错

ui_home.c:1161:33: error: invalid type argument of ‘->’ (have ‘int’)
 1161 |     int x = endev_get_tp_coord()->x1;
      |                                 ^~
ui_home.c:1162:33: error: invalid type argument of ‘->’ (have ‘int’)
 1162 |     int y = endev_get_tp_coord()->y1;

img

代码


img


img

#if (TP_TEST_FUNC == ENABLE)
static Ux_RECT tp_coord = {0,0, 0, 0};

PUx_RECT endev_get_tp_coord(void)
{
    return (PUx_RECT)&tp_coord;
}
#endif


img

    #if (TP_TEST_FUNC == ENABLE)
    int x = endev_get_tp_coord()->x1;
    int y = endev_get_tp_coord()->y1;
    lv_label_set_text_fmt(HomeBar_objs.tp_test_str, "( %d - %d )", x,y);
    #endif

  • 写回答

3条回答 默认 最新

  • 透明水晶 2024-04-10 19:04
    关注

    换一种写法

    #if (TP_TEST_FUNC == ENABLE)
    static Ux_RECT tp_coord = {0,0, 0, 0};
    
    void  endev_get_tp_coord(PUx_RECT data)
    {
        data->x1 = tp_coord.x1;
        data->y1 = tp_coord.y1;
    }
    #endif
    
    

        #if (TP_TEST_FUNC == ENABLE)
        Ux_RECT tp_data = {0};
        endev_get_tp_coord(&tp_data);
        lv_label_set_text_fmt(HomeBar_objs.tp_test_str, "( %d - %d )", tp_data.x1, tp_data.y1);
        #endif
    
    

    另一种报错

    ui_home.c:1161:5: error: unknown type name ‘Ux_RECT’
     1161 |     Ux_RECT tp_data = {0};
          |     ^~~~~~~
    ui_home.c:1163:75: error: request for member ‘x1’ in something not a structure or union
     1163 |     lv_label_set_text_fmt(HomeBar_objs.tp_test_str, "( %d - %d )", tp_data.x1, tp_data.y1);
          |                                                                           ^
    ui_home.c:1163:87: error: request for member ‘y1’ in something not a structure or union
     1163 |     lv_label_set_text_fmt(HomeBar_objs.tp_test_str, "( %d - %d )", tp_data.x1, tp_data.y1);
          |
    
    
    

    估计是编译器找不到数据的类型了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 4月18日
  • 已采纳回答 4月10日
  • 修改了问题 4月10日
  • 创建了问题 4月10日

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100