[omniORB] Problem of CORBA::String in MFC Application

Diego Roig diego.roig@grupoclave.com
Fri, 26 Nov 1999 16:07:22 -0300


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01BF3841.77DE9B10
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

In an ISO C++ compiler string literals are of const char* type. gcc =
2.95.2
conforms the standard in that point. There=B4s an option to make them =
of type
char*. (-fwritable-strings I think)


-----Mensaje original-----
De: Guy Trudel [mailto:gtrudel@mediatrix.com]
Enviado el: viernes 26 de noviembre de 1999 15:51
Para: Omniorb-List (E-mail)
CC: 'Ji-Yong D. Chung'
Asunto: RE: [omniORB] Problem of CORBA::String in MFC Application


> It seems to me, if there is CORBA::String_var::operator=3D(const char =
*),
both of the preceding statements should yield the same result.

If you have only CORBA::String_var(const char*) everything is ok, but
Corba::String_var also have CORBA::String_var(char*) and since string
literals are not <const char*>, this is the copy constructor called.

inline _CORBA_String_var(char *p) { _data =3D p; }

and not

inline _CORBA_String_var(const char* p)=20
{=20
	if( p ) _data =3D string_dup(p);
  	else    _data =3D 0;=20
}

Guy Trudel


------_=_NextPart_001_01BF3841.77DE9B10
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2448.0">
<TITLE>RE: [omniORB] Problem of CORBA::String in MFC =
Application</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>In an ISO C++ compiler string literals are of const =
char* type. gcc 2.95.2 conforms the standard in that point. There=B4s =
an option to make them of type char*. (-fwritable-strings I =
think)</FONT></P>
<BR>

<P><FONT SIZE=3D2>-----Mensaje original-----</FONT>
<BR><FONT SIZE=3D2>De: Guy Trudel [<A =
HREF=3D"mailto:gtrudel@mediatrix.com">mailto:gtrudel@mediatrix.com</A>]<=
/FONT>
<BR><FONT SIZE=3D2>Enviado el: viernes 26 de noviembre de 1999 =
15:51</FONT>
<BR><FONT SIZE=3D2>Para: Omniorb-List (E-mail)</FONT>
<BR><FONT SIZE=3D2>CC: 'Ji-Yong D. Chung'</FONT>
<BR><FONT SIZE=3D2>Asunto: RE: [omniORB] Problem of CORBA::String in =
MFC Application</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>&gt; It seems to me, if there is =
CORBA::String_var::operator=3D(const char *),</FONT>
<BR><FONT SIZE=3D2>both of the preceding statements should yield the =
same result.</FONT>
</P>

<P><FONT SIZE=3D2>If you have only CORBA::String_var(const char*) =
everything is ok, but</FONT>
<BR><FONT SIZE=3D2>Corba::String_var also have CORBA::String_var(char*) =
and since string</FONT>
<BR><FONT SIZE=3D2>literals are not &lt;const char*&gt;, this is the =
copy constructor called.</FONT>
</P>

<P><FONT SIZE=3D2>inline _CORBA_String_var(char *p) { _data =3D p; =
}</FONT>
</P>

<P><FONT SIZE=3D2>and not</FONT>
</P>

<P><FONT SIZE=3D2>inline _CORBA_String_var(const char* p) </FONT>
<BR><FONT SIZE=3D2>{ </FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>if( p ) =
_data =3D string_dup(p);</FONT>
<BR><FONT SIZE=3D2>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
else&nbsp;&nbsp;&nbsp; _data =3D 0; </FONT>
<BR><FONT SIZE=3D2>}</FONT>
</P>

<P><FONT SIZE=3D2>Guy Trudel</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01BF3841.77DE9B10--