Like Tree1Likes
  • 1 Post By iMalc

previous definition is here

This is a discussion on previous definition is here within the C Programming forums, part of the General Programming Boards category; I've got a struct Code: typedef struct _entry{ bool is_submenu; gchar *name; gchar *command; gchar *icon_path; struct _entry *subentry; } ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    11

    previous definition is here

    I've got a struct

    Code:
     typedef struct _entry{
        bool is_submenu;
    
    
        gchar *name;
        gchar *command;
        gchar *icon_path;
    
    
        struct _entry *subentry;
    } entry;
    Which gives me the following error message in clang

    Code:
    src/common.h:5:16: error: redefinition of '_entry'
    typedef struct _entry
                   ^
    src/common.h:5:16: note: previous definition is here
    typedef struct _entry
                   ^
    Makes no sense to me. GCC gives the same error. I tried out a minimal example...

    Code:
    typedef struct test_struct
    {
        int some_data;
        struct test_struct *next_struct;
    } test;
    
    
    int main(void)
    {
        return 0;
    }
    And it compiles just fine. Any ideas?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    So if you change nothing else except _entry to something NOT beginning with an underscore (which is reserved by the way), do you still have the problem?
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    11
    Yeah, same deal.

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,299
    My guess would be missing header include guards.
    AaronP likes this.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  5. #5
    Registered User
    Join Date
    Nov 2011
    Posts
    11
    For chrissake, I think you're right. I hate programming.

    In a masochistic sort of way.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 02-25-2012, 09:27 AM
  2. Multiple definition error, one definition
    By frog in forum C++ Programming
    Replies: 9
    Last Post: 10-21-2010, 03:15 AM
  3. warning: this is the location of the previous definition
    By Boschwakka in forum C Programming
    Replies: 1
    Last Post: 07-21-2010, 07:47 AM
  4. My Previous Project...
    By thecrazycoerian in forum C++ Programming
    Replies: 1
    Last Post: 01-07-2004, 09:42 AM
  5. First Last Next and Previous
    By Unregistered in forum C Programming
    Replies: 7
    Last Post: 04-17-2002, 10:05 AM

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