Struct definition problem

This is a discussion on Struct definition problem within the C Programming forums, part of the General Programming Boards category; I defined following struct: Code: typedef struct COLABR { char *className; COLABR *next ; } COLABR; It looks well but ...

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

    Struct definition problem

    I defined following struct:

    Code:
    typedef struct COLABR {
      char     *className;
      COLABR   *next     ;
    } COLABR;
    It looks well but I get errors:
    error: syntax error befor COLBAR
    warning: no semicolon at end of struct or union;
    warning: type defaults to 'int' in declaration 'COLABR'
    warning: data definition has no type or storage class

    I can't see any problem but maybe I'm blind.

  2. #2
    cas
    cas is offline
    Registered User
    Join Date
    Sep 2007
    Posts
    991
    The typedef for the struct hasn't been created while you're inside the struct. You need:
    Code:
    typedef struct COLABR
    {
      struct COLABR *next;
    } COLABR;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem with struct
    By megazord in forum C Programming
    Replies: 3
    Last Post: 12-25-2009, 09:44 AM
  2. Help me please.
    By yann in forum C Programming
    Replies: 15
    Last Post: 09-29-2009, 09:04 PM
  3. pointer problem or so...
    By TL62 in forum C Programming
    Replies: 19
    Last Post: 01-12-2008, 10:45 PM
  4. Looking for a way to store listbox data
    By Welder in forum C Programming
    Replies: 20
    Last Post: 11-01-2007, 11:48 PM
  5. Replies: 10
    Last Post: 05-18-2006, 11:23 PM

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