1

I'm using CCS v6 and there was an error about structure grammar.

typedef struct _mem_ptr_t
{
    struct _mem_ptr_t *next;    ///< Next pointer in memory
    uint8    alloc;              ///< Allocated
    struct  mmem mmem_ptr;      ///< The actual pointer to the pointer to the mem block
} mem_ptr_t;

struct mmem {
  struct mmem *next;
  unsigned int size;
  void *ptr;
};

above code was original state. but there was an error. "#71 incomplete type is not allowed "

So, I had changed code "struct mmem mmem_ptr; " -> "struct mmem *mmem_ptr; " When i had compiling, that part was passed.

But another part was occurred error.

if ((mem_ptr = mac_scan_alloc()) != NULL) {
        memcpy(&SCAN_ENTRY(mem_ptr)->oord_addr, src_addr, sizeof(address_t));
        SCAN_ENTRY(mem_ptr)->superfrm_spec = superframe_spec;
        SCAN_ENTRY(mem_ptr)->coord_pan_id = src_pan_id;
        SCAN_ENTRY(mem_ptr)->channel = channel;
    }
#define SCAN_ENTRY(m)  ((pan_descr_t *)MMEM_PTR(&m->mmem_ptr)) 

There was an error "#133 expression must have pointer-to-struct-or-union type"

I had already looked related question about this problem. but i couldn't understand to solve above problem. Expression must have pointer to struct or union error

What should i fix my code to solve this problem?

Community
  • 1
  • 1
Won Hee Lee
  • 65
  • 2
  • 9

1 Answers1

4

struct _mem_ptr_t uses struct mmem before it is defined. So swap the definitions:

struct mmem {
  struct mmem *next;
  unsigned int size;
  void *ptr;
};

typedef struct _mem_ptr_t
{
    struct _mem_ptr_t *next;    ///< Next pointer in memory
    uint8    alloc;              ///< Allocated
    struct  mmem mmem_ptr;      ///< The actual pointer to the pointer to the mem block
} mem_ptr_t;

Changing the definition of mmem_ptr from struct mmem to struct mmem * doesn't work because you're changing its type, so any code that uses it is not doing so properly.

dbush
  • 205,898
  • 23
  • 218
  • 273