Thread: struct problems.

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    61

    struct problems.

    I have a header file and a normal c-file. When trying to compile them I get a few errors. I don't know what to do about them. Here are the files :
    Code:
    //H_linked_list.h : 
    struct ListNode;
    
    typedef struct _List {
    	ListNode *first;
    	ListNode *last;
    	int size;
    } List;
    
    List initList();
    void freeList (List *list);
    void addNode (List *list, void *data);
    void freeNode (List *list, void *data);
    void *getData (ListNode *node);
    ListNode *next (ListNode *node);
    ListNode *prev (ListNode *node)
    ListNode *getFirst (List *list);
    ListNode *getLast (List *list);
    int getSize (List *list);
    Code:
    //H_linked_list.c : 
    #include "H_linked_list.h"
    
    typedef struct _ListNode {
    	ListNode *next;
    	ListNode *prev;
    	void *data;
    } ListNode;
    
    int main(){
    	return 0;
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Code:
    typedef struct _List {
    	struct _List *first;
    	struct _List *last;
    	int size;
    } List;
    You must use the tag name of the struct when referring to itself
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting from C to C++
    By Taka in forum C++ Programming
    Replies: 5
    Last Post: 04-08-2009, 02:16 AM
  2. Replies: 1
    Last Post: 12-03-2008, 03:10 AM
  3. weird typedef struct problems
    By olidem in forum C Programming
    Replies: 3
    Last Post: 07-28-2008, 02:59 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. towers of hanoi problem
    By aik_21 in forum C Programming
    Replies: 1
    Last Post: 10-02-2004, 01:34 PM