va_start and template functions do not compile under gcc 2.7.2

F

frankg

When I compile this file
------------------------------------------------------
#include <stdarg.h>


template <class Any>
void var_arg_func(int dimension_count, ...)
{
int dimensions[4];
va_list ap;

va_start(ap, dimension_count); // <- error


for (int i = 0; i < 3; i++)
{
dimensions = va_arg(ap,int); // <- error
}
}
------------------------------------------------------
I get the following obscure error message:
test.cpp:10: sorry, not implemented: initializer contains unrecognized
tree code
test.cpp:15: sorry, not implemented: initializer contains unrecognized
tree code

If I make the function to be non-templated, it compiles.

Either version compiles under MSVC++ 6.0.

I am using the gcc 2.7.2 that ships with Tornado 2.0 from
WindRiver.

Can anyone explain this error message?
I need to get this code to compile.

I have a templated class that I wrote that implements a
multi-dimensional container. Since it is a container it must be
templated.
Being multi-dimensional the functions that require an index use
the elipsis ... operator.
 
V

Victor Bazarov

frankg said:
When I compile this file
------------------------------------------------------
[...]
------------------------------------------------------
I get the following obscure error message:
test.cpp:10: sorry, not implemented: initializer contains unrecognized ^^^^^^^^^^^^^^^^^^^^^^
tree code
[...]
I am using the gcc 2.7.2 that ships with Tornado 2.0 from
WindRiver.

Can anyone explain this error message?
I need to get this code to compile.

What word of "sorry, not implemented" do you not understand?

GCC has already progressed to the next major version. Perhaps
you need to update your compiler...

Victor
 
G

galathaea

:
: When I compile this file
: ------------------------------------------------------
: #include <stdarg.h>
:
:
: template <class Any>
: void var_arg_func(int dimension_count, ...)
: {
: int dimensions[4];
: va_list ap;
:
: va_start(ap, dimension_count); // <- error
:
:
: for (int i = 0; i < 3; i++)
: {
: dimensions = va_arg(ap,int); // <- error
: }
: }
: ------------------------------------------------------
: I get the following obscure error message:
: test.cpp:10: sorry, not implemented: initializer contains unrecognized
: tree code
: test.cpp:15: sorry, not implemented: initializer contains unrecognized
: tree code
:
: If I make the function to be non-templated, it compiles.
:
: Either version compiles under MSVC++ 6.0.
:
: I am using the gcc 2.7.2 that ships with Tornado 2.0 from
: WindRiver.
:
: Can anyone explain this error message?
: I need to get this code to compile.
:
: I have a templated class that I wrote that implements a
: multi-dimensional container. Since it is a container it must be
: templated.
: Being multi-dimensional the functions that require an index use
: the elipsis ... operator.

The code you posted assumes a set size of 3 integer arguments, so getting
that code to compile would be as simple as taking out the ellipses and
putting in an array argument and reading that. However, I don't think the
code you posted is what you want to actually compile (since your function is
parameterized but never uses the template parameter and the ellipses suggest
many possible numbers of arguments).

If the ellipses mean you just want to get passed a collection of values you
know are integers, just set a second argument of std::vector<int>, if they
are parametrized by the template, set a second argument of std::vector<Any>,
and if the arguments really must vary in type, you need to include a
descriptor argument which specifies what the format of those arguments are
and then you can try a std::vector<boost::any> or some other generic type
container. I am not sure why your code will not compile, but there seem to
be several alternate designs that might be more typesafe as well as being
more likely to compile.
 
F

frankg

What word of "sorry, not implemented" do you not understand?
GCC has already progressed to the next major version. Perhaps
you need to update your compiler...

Victor

Thank you for your courteous response. I am forced to use this version
of gcc because Windriver ships binary objects without source. If I try
to move to a newer version of gcc that has different parameter passing
assumptions bad things will happen.
 
J

Joe Durusau

frankg said:
Thank you for your courteous response. I am forced to use this version
of gcc because Windriver ships binary objects without source. If I try
to move to a newer version of gcc that has different parameter passing
assumptions bad things will happen.

I've never used C++ stuff in VxWorks, but there are folks around who
have switched to a never compiler with varying degrees of success.
You might try searching google. Also, you really are compiling
with g++ as opposed to gcc, aren't you? This is expecially important
if you are using a windows host as your development machine.

You might also call the local FAE and explain your specific
problem. They may have a workaround.

Speaking only for myself,

Joe Durusau
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top