[omniORB] "Segmentation Fault" Error while handling client's requests..

David Bellette david.bellette@nec.com.au
Thu, 17 Jan 2002 09:44:07 +1100


>   CORBA::String_var src = "Hello!  i am gamma.....";
> >
> >                                               ^^^^^^^^^^^^^^^^^^^^^^^^^
> > CORBA::String_var src =CORBA::string_dup("Hello!  i am gamma.....");
>
> That's an interesting point. With a modern C++ compiler, the two lines
> of code are equivalent, since string literals are const char* in
> standard C++. Older C++ compilers treat string literals as char*,
> though, and directly initialising a String_var with them would cause a
> problem.
> Duncan.


MS VC++ 6.0 takes string literals as char*, and therefore, has calls the char* constructor instead of the const char* constructor.

You can either do :
CORBA::String_var src =CORBA::string_dup("Hello!  i am gamma.....");

or you can cast the string to get around the problem:

CORBA::String_var src = (const char*)"Hello!  i am gamma.....";


David