Error: redefinition of typedef 'list_t

This is a discussion on Error: redefinition of typedef 'list_t within the C Programming forums, part of the General Programming Boards category; I am getting following error on compiling using gcc. I am currently using gcc version 3.4.6 Can any one tell ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    1

    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.
    Code:
    #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;
    
    
    #endif

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    You can remove this line:
    Code:
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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, 11:36 AM
  3. Please STICKY this- vital to MSVC 6 dev - BASETSD.h
    By VirtualAce in forum Game Programming
    Replies: 11
    Last Post: 03-15-2005, 08:22 AM
  4. build errors migrated from dx9b to dx9c sdk
    By reanimated in forum Game Programming
    Replies: 4
    Last Post: 12-17-2004, 06: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, 11:54 AM

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