0

I am getting following error for class which wrapper for va_list.

error: "<invalid operator>" declared as function returning an array Here is the class definition.

1 #include <stdarg.h>
2 #ifndef __va_size
3 #define   __va_size(type) (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
4 #endif // __va_size
5 
6    class VAList {
7     protected:
8      va_list ap;
9    public:
10      template<class _Type> VAList(_Type const& last) {
11        va_copy(ap ,*((va_list*)((char *)&(last) + __va_size(last))));
12        }
13      ~VAList() {
14         va_end(ap);
15        }
16      operator va_list() const {
17        return ap;
18        }
19    };

VAList.hh:16: error: <invalid operator> declared as function returning an array

gcc version 4.4.6.

Please help to fix this error.

Cameron
  • 96,106
  • 25
  • 196
  • 225
  • 2
    `__va_size` is a [reserved identifier](http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier). – chris Jul 11 '13 at 05:41
  • 3
    [`va_list` is an array](http://stackoverflow.com/a/4958507/21475), so you can't return anything of that type directly. – Cameron Jul 11 '13 at 05:45
  • 1
    I don't see the need for a wrapper for `va_list`. If you can, upgrade your compiler and use variadic templates. If you can't, use Boost's. – chris Jul 11 '13 at 05:46

0 Answers0