Thread: Another 'dereferencing pointer to incomplete type'

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    33

    Another 'dereferencing pointer to incomplete type'

    Essence of the code regarding issue:
    Code:
    typedef struct BMS_Chkmem{
      int elemsize;
    } BMS_CHKMEM;  
    
    typedef struct BMS_Blkmem{
      BMS_CHKMEM* chkmemhash[1013];
    } BMS_BLKMEM;
    
    typedef struct SCIP_Mem{
      BMS_BLKMEM* setmem;
    } SCIP_MEM;
    
    void* allocMemory(size)
    {
      void* ptr;
      ptr = malloc(size)
      return ptr;
    }
    
    BMS_BLKMEM* createBlockMemory(void)
    {
      int i;
      BMS_BLKMEM* blkmem;
      blkmem = allocMemory(sizeof(*(blkmem)));
    
      for (i=0; i < 1013; i++)
      {
        blkmem->chkmemhash[i] = NULL;
      }
    
      return blkmem;
    }
    
    void memCreate(SCIP_MEM** mem)
    {
      mem = allocMemory(sizeof(**(mem)));
    
      (*mem)->setmem = createBlockMemory();
    
      if ( (*mem)->setmem->chkmemhash[60] == NULL)
        printf("Is null\n");
      else
        printf("Is not null\n");
    }
    
    int main(void)
    {
      SCIP_MEM* mem;
      memCreate(&mem);
      return 0;
    }
    The above code is simple the essence of what I'm using, I'm not even sure if it would compile, but I hope it contains everything needed.

    memCreate is called, and is passed a pointer of a higher struct, which at the time is NULL, the idea being to allocate it some memory, and initialize it. When I try to compile the code that this is taken from, I get an error of:
    dereferening pointer to incomplete type
    This error relates to:
    if ( (*mem)->setmem->chkmemhash[60] == NULL)
    From what I can see, this should work, but clearly I'm overlooking something.
    Last edited by thealmightyone; 11-24-2010 at 05:26 PM. Reason: Edit to code to make it compiliable.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. error: dereferencing pointer to incomplete type
    By kiros88 in forum C Programming
    Replies: 4
    Last Post: 09-16-2009, 02:43 PM
  2. error: dereferencing pointer to incomplete type
    By surlyTomato in forum C Programming
    Replies: 10
    Last Post: 08-22-2009, 08:04 AM
  3. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  4. Replies: 5
    Last Post: 04-04-2009, 03:45 AM
  5. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM