derefrencing pointer to incomplete type error

This is a discussion on derefrencing pointer to incomplete type error within the Linux Programming forums, part of the Platform Specific Boards category; I 'm writing a code to traverse all allocated slabs. First I traverse cache list through "cache_chain". my code is: ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    5

    derefrencing pointer to incomplete type error

    I 'm writing a code to traverse all allocated slabs. First I traverse cache list through "cache_chain". my code is:
    Code:
    struct list_head cache_chain, *p;
    list_for_each(p, &cache_chain){
        kmem_cache_t *cachep=list_entry(p, struct kmem_cache_t, next); 
        ...
    }
    but when compiling I receive following errors:
    error: dereferencing pointer to incomplete type
    error: invalid use of incomplete typedef 'keme_cache_t'
    what should I do?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    error: invalid use of incomplete typedef 'keme_cache_t'
    Is that bolded part just a typo? The error lists keme_cache_t, but your code has kmem_cache_t.

    If it is just a typo, then it's appears to be a problem where you typedef'd a type, but didn't include the header file for that type.
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #3
    Registered User
    Join Date
    Sep 2009
    Posts
    5
    yes, that's a typo.
    I think the error is because of one of these two reasons:
    1. the header file for kmem_cache_t is not included: I tried to find the header file but I couldn't.
    2. cache_chain is not initialized. this reason is more logical for me, but I don't know how to initialize it. can you help me, please?
    and, thanks for first reply.

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by aliasghar View Post
    1. the header file for kmem_cache_t is not included: I tried to find the header file but I couldn't.
    Because it doesn't exist. I grepped thru the kernel headers and /usr/include. It is not referred to anywhere:

    Then I googled this

    [PATCH] Remove the deprecated "kmem_cache_t" typedef from slab.h.

    apparently kmem_cache_t used to be in slab.h (a kernel header) but is no longer used in the kernel tree so has been depreciated right out.

    I think the original typdef is in that post tho, so you could just paste it in.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 02:17 AM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-30-2005, 12:21 AM
  5. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 06:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21