Thread: Error: redefinition of typedef 'list_t

  1. #1
    Registered User
    Join Date
    May 2009

    Error: redefinition of typedef 'list_t

    I am getting following error on compiling using gcc. I am currently using gcc version 3.4.6 Can any one tell me what is wrong in the code. And how can I recover from this.

    list.h:39: error: redefinition of typedef 'list_t'
    list.h:29: error: previous declaration of 'list_t' was here

    The def in list.h is as as shown below.
    #ifndef _LIST_H
    #define _LIST_H
    typedef struct list_t list_t;
    typedef struct
            void                    *next;          
            void                    *prev;         
            void                    *data;         
            int                     datasize;
            list_t                  *list;        
    } list_item_t;
    typedef struct list_t
            list_item_t             *head;         
            list_item_t             *tail;         
            list_item_t             *pMark;       
            list_t                  *pPar;      
    } list_t;

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    You can remove this line:
    typedef struct list_t list_t;
    Or you can remove the typedef from the definition of struct list_t.

    By the way, do not use _LIST_H for your header inclusion guard. Names that begin with an underscore followed by an uppercase letter are reserved to the implementation for any use.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 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
  2. Need help understanding info in a header file
    By hicpics in forum C Programming
    Replies: 8
    Last Post: 12-02-2005, 12:36 PM
  3. Please STICKY this- vital to MSVC 6 dev - BASETSD.h
    By VirtualAce in forum Game Programming
    Replies: 11
    Last Post: 03-15-2005, 09:22 AM
  4. build errors migrated from dx9b to dx9c sdk
    By reanimated in forum Game Programming
    Replies: 4
    Last Post: 12-17-2004, 07:35 AM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 12:54 PM