Typedef with GCC/G++

From: Jeff Mott (mjeff1_at_twcny.rr.com)
Date: 11/19/04


Date: 18 Nov 2004 21:46:54 -0800

Given the following example code

  typedef
      struct fubar *
      fubar;

  struct fubar
  {
  };

  int main(void)
  {
      return 0;
  }

GCC on Windows will compile this fine, but G++ throws an error saying

  3: error: conflicting types for 'typedef struct fubar*fubar'
  2: error: previous declaration as 'struct fubar'
  6: error: conflicting types for 'struct fubar'
  3: error: previous declaration as 'typedef struct fubar*fubar'

Now I know I can avoid this error by simply renaming the struct to
something else, but I'd prefer to understand why this is interpreted
differently.



Relevant Pages

  • Re: Typedef with GCC/G++
    ... > struct fubar * ... > int main ... > Now I know I can avoid this error by simply renaming the struct to ...
    (comp.lang.c)
  • Re: Typedef with GCC/G++
    ... mjeff1@twcny.rr.com (Jeff Mott) writes: ... > struct fubar * ... > int main ...
    (comp.lang.c)
  • Re: Typedef with GCC/G++
    ... > struct fubar * ... > int main ... your struct has no members. ...
    (comp.lang.c)