[omniORB] Problem inserting an array of structs containing
strings into an any
Brian Neal
bgneal at gmail.com
Fri Jan 6 08:01:17 GMT 2006
On 1/5/06, Duncan Grisby <duncan at grisby.org> wrote:
> On Thursday 5 January, Brian Neal wrote:
>
> [...]
> > I get a segfault when I insert the forany into the any at the line
> > marked ****
>
> [...]
> > I have changed the struct member b from a string to a long, an any,
> > and a sequence of longs, and when I do, I don't get a seqfault.
>
> The problem is that you have not initialised the ORB. Inserting a string
> into an Any involves checking the code set conversions, and they aren't
> initialised until ORB_init() is called.
Boy is my face red! Thanks, this was the problem...
Okay, let me then press ahead with the footnote to my original
question. I have to write the following:
Test::TestStructArray_forany fa;
if (a >>= fa) {
std::copy(&fa[0UL], &fa[0UL] + numElems,
std::ostream_iterator<Test::TestStruct>(std::cout, "\n"));
}
Notice the 0UL. If I don't, and use plain old int 0 to index into the
forany, g++ 3.4.4 gives me the following error:
main.cpp:46: error: ISO C++ says that these are ambiguous, even though
the worst conversion for the first is better than the worst conversion
for the second:
/usr/local/include/omniORB4/templatedecls.h:1143:
note: candidate 1:
T& _CORBA_Array_Variable_Forany<T_Helper, T>::operator[](_CORBA_ULong)
[with T_Helper = Test::TestStructArray_copyHelper, T = Test:
:TestStructArray_slice]
main.cpp:46: note: candidate 2:
operator[](Test::TestStructArray_slice*, int) <built-in>
I don't get this at all, as I don't even see candidate 2 in
templatedecls.h (and g++ doesn't give a line number for it). ?????
I did notice that further on down in the file templatedecls.h, for the
template class _CORBA_Array_Fixed_Forany<>, there is this extra set of
operator[] functions for gnu:
#if defined(__GNUG__) && __GNUG__ == 3 && __GNUC_MINOR__ >= 4
// g++ thinks the operators with ULong arguments are ambiguous when
// used with int literals. This sorts it out.
inline T& operator[] (int index_) { return *(pd_data + index_); }
inline const T& operator[] (int index_) const {
return *( (const T*) (pd_data + index_));
}
#endif
?
Thanks!
BN
More information about the omniORB-list
mailing list