Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

c++ - Error: expression must be a pointer to a complete object type (?)

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);
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...