[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: GCC 4.3 C++ question



> class SomeClass
> {
>  public:
>    SomeClass();
>    // more stuff...
>  protected:
>    typedef struct _mylist mylist_t;
>    struct _mylist {
>      mylist_t *next;  // here
>      void *dataM
>    };
> };

Please note that this does not compile with gcc-4.1 or gcc-4.3. This is
not due to an update in GCC, but rather to malformed code.

%g++ -c test.cc
test.cc:12: error: expected ';' before '}' token
test.cc:12: error: expected `;' before '}' token

There is no valid "_mylist" type in scope at the typedef, so mylist_t
is invalid and it's use later shows this error.

Change to:

  struct _mylist 
  {
    _mylist *next;  // NB
    void *dataM;
  };

  typedef _mylist mylist_t;

-benjamin


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]