错误:表达式必须是指向完整对象类型的指针(?)

发布于 2024-12-17 05:02:26 字数 747 浏览 3 评论 0原文

这是我需要修改的C 函数。我试图将以前的 4 个字节的地址从“box”开始与 rt_tsk_self() 返回的 U32 值进行比较,但它只是给了我一个错误:“表达式必须是指向完整的对象类型”。

/*--------------------------- rt_free_box -----------------------------------*/

int rt_free_box (void *box_mem, void *box) {
  /* Free a memory block, returns 0 if OK, 1 if box does not belong to box_mem */
 if !(defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M))
  int irq_dis;
 endif

  if (box < box_mem || box > ((P_BM) box_mem)->end) {
    return (1);
  }

  //MODIFIED***********
  if (*(box-4) != rt_tsk_self()) {  //<--- error:  #852: expression must be a pointer to a complete object type
    return (1);
  }
  //***************

/* 
other unrelated code
*/
  return (0);
}

This is the function in C that I need to modify. I am trying to have PREVIOUS 4 bytes of address starting from "box" to compare with a returned U32 value from rt_tsk_self(), but it just gives me the error that "expression must be a pointer to a complete object type".

/*--------------------------- rt_free_box -----------------------------------*/

int rt_free_box (void *box_mem, void *box) {
  /* Free a memory block, returns 0 if OK, 1 if box does not belong to box_mem */
 if !(defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M))
  int irq_dis;
 endif

  if (box < box_mem || box > ((P_BM) box_mem)->end) {
    return (1);
  }

  //MODIFIED***********
  if (*(box-4) != rt_tsk_self()) {  //<--- error:  #852: expression must be a pointer to a complete object type
    return (1);
  }
  //***************

/* 
other unrelated code
*/
  return (0);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故事与诗 2024-12-24 05:02:26

您正在尝试取消引用 void *。那是行不通的。试试这个:

if (*(((uint32_t *)box)-1) != rt_tsk_self()) {

You're trying to dereference a void *. That won't work. Try this instead:

if (*(((uint32_t *)box)-1) != rt_tsk_self()) {
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文