Boost logo

Boost Testing :

From: David Abrahams (dave_at_[hidden])
Date: 2005-05-29 11:45:41


Hartmut Kaiser <hartmut.kaiser_at_[hidden]> writes:

> Hi all,
>
> does anybody of the CW tester have some time to look at this issue:
> http://tinyurl.com/du5w8 (all CW's toolsets show a similar error)?
> Essentially the problem boils down to:
>
> #define INIT_DATA_SIZE 176
>
> template <typename T>
> struct A
> {
> typedef T base_type;
>
> struct data {
> typename base_t::callback_type tokencb;
                       ^^^^^^
                       base_type

> // other members here
> };
>
> static data const init_data[INIT_DATA_SIZE];
> };
>
> template <typename T>
> typename A<T>::data const A<T>::init_data[INIT_DATA_SIZE] =
> {
> // initialisation elements go here....
> };
>
> The compilers claim:
>
> # Error: ^
> # identifier 'A::init_data' redeclared
> # was declared as: 'const A::lexer_data[176]'
> # now declared as: 'const A::lexer_data[176]'
>
> I've added the concrete count of initialisation elements later on, the same
> error occurs when the arrays are declared and defined as 'init_data[]'
> instead of 'init_data[INIT_DATA_SIZE]'.
>
> Any ideas?

Clearly a bug; I reported it to MW. This workaround may be painful,
but it works:

  #define INIT_DATA_SIZE 176

  template <typename T>
  struct B
  {
      typedef T base_type;

      struct data {
          typename base_type::callback_type tokencb;
          // other members here
      };

  };

  template <typename T>
  struct A : B<T>
  {

      static typename B<T>::data const init_data[INIT_DATA_SIZE];
  };

  template <typename T>
  typename B<T>::data const A<T>::init_data[INIT_DATA_SIZE] =
  {
  // initialisation elements go here....
  };

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost-testing list run by mbergal at meta-comm.com