FW: [omniORB] Compiler warnings (casting from const char* to
char * and vice versa)
Matej Kenda
matej.kenda@hermes.si
Mon, 11 Feb 2002 17:57:32 +0100
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_000_01C1B31D.32ADA9B0
Content-Type: text/plain
I didn't see that define earlier.
Attached is the new diff.
Matej
-----Original Message-----
From: Duncan Grisby [mailto:dgrisby@uk.research.att.com]
Sent: Monday, February 11, 2002 4:04 PM
To: Matej Kenda
Cc: omniORB-list (omniorb-list@uk.research.att.com)
Subject: Re: FW: [omniORB] Compiler warnings (casting from const char* to
char * and vice versa)
On Thursday 31 January, Matej Kenda wrote:
> OK. The patch (unified diff) file for omniORB3 is attached.
CORBA_sysdep.h already defines the symbol HAS_Cplusplus_const_cast if
const_cast is supported, so you don't need to do it again. I'd appreciate it
if you could reformulate your patch to use that.
Cheers,
Duncan.
--
-- Duncan Grisby \ Research Engineer --
-- AT&T Laboratories Cambridge --
-- http://www.uk.research.att.com/~dpg1 --
------_=_NextPart_000_01C1B31D.32ADA9B0
Content-Type: application/octet-stream;
name="const_cast.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="const_cast.diff"
diff --unified -b -B omni/include/omniORB3/CORBA.h =
includefix/omniORB3/CORBA.h=0A=
--- omni/include/omniORB3/CORBA.h Fri Jun 1 15:56:57 2001=0A=
+++ includefix/omniORB3/CORBA.h Mon Feb 11 17:50:53 2002=0A=
@@ -423,7 +423,11 @@=0A=
=0A=
struct from_string {=0A=
from_string(const char* s, ULong b, Boolean nocopy =3D 0)=0A=
+#ifdef HAS_Cplusplus_const_cast=0A=
+ : val(const_cast<char*>(s)), bound(b), nc(nocopy) { }=0A=
+#else=0A=
: val((char*)s), bound(b), nc(nocopy) { }=0A=
+#endif=0A=
from_string(char* s, ULong b, Boolean nocopy =3D 0)=0A=
: val(s), bound(b), nc(nocopy) { } // deprecated=0A=
=0A=
diff --unified -b -B omni/include/omniORB3/stringtypes.h =
includefix/omniORB3/stringtypes.h=0A=
--- omni/include/omniORB3/stringtypes.h Tue Sep 19 11:10:33 2000=0A=
+++ includefix/omniORB3/stringtypes.h Mon Feb 11 17:50:53 2002=0A=
@@ -187,10 +188,18 @@=0A=
typedef char* ptr_t;=0A=
=0A=
inline _CORBA_String_member()=0A=
+#ifdef HAS_Cplusplus_const_cast=0A=
+ : _ptr(const_cast<char*>(omni::empty_string)) {}=0A=
+#else=0A=
: _ptr((char*) omni::empty_string) {}=0A=
+#endif=0A=
=0A=
inline _CORBA_String_member(const _CORBA_String_member& s) =0A=
+#ifdef HAS_Cplusplus_const_cast=0A=
+ : _ptr(const_cast<char*>(omni::empty_string)) {=0A=
+#else=0A=
: _ptr((char*)omni::empty_string) {=0A=
+#endif=0A=
if (s._ptr && s._ptr !=3D omni::empty_string)=0A=
_ptr =3D _CORBA_String_var::string_dup(s._ptr);=0A=
}=0A=
@@ -319,7 +328,11 @@=0A=
else=0A=
pd_data =3D 0;=0A=
} else {=0A=
+#ifdef HAS_Cplusplus_const_cast=0A=
+ pd_data =3D const_cast<char*>(s);=0A=
+#else=0A=
pd_data =3D (char*)s;=0A=
+#endif=0A=
}=0A=
return *this;=0A=
}=0A=
@@ -346,7 +359,11 @@=0A=
else=0A=
pd_data =3D 0;=0A=
} else=0A=
+#ifdef HAS_Cplusplus_const_cast=0A=
+ pd_data =3D const_cast<char*>((const char*)s);=0A=
+#else=0A=
pd_data =3D (char*)(const char*)s;=0A=
+#endif=0A=
return *this;=0A=
}=0A=
=0A=
@@ -356,9 +373,17 @@=0A=
if( (const char*)s && (const char*) s !=3D =
omni::empty_string)=0A=
pd_data =3D _CORBA_String_var::string_dup((const char*)s);=0A=
else=0A=
+#ifdef HAS_Cplusplus_const_cast=0A=
+ pd_data =3D const_cast<char*>((const char*)s);=0A=
+#else=0A=
pd_data =3D (char*)(const char*)s;=0A=
+#endif=0A=
} else=0A=
+#ifdef HAS_Cplusplus_const_cast=0A=
+ pd_data =3D const_cast<char*>((const char*)s);=0A=
+#else=0A=
pd_data =3D (char*)(const char*)s;=0A=
+#endif=0A=
return *this;=0A=
}=0A=
=0A=
@@ -559,7 +584,11 @@=0A=
=0A=
// If we've shrunk we need to clear the entries at the top.=0A=
for( _CORBA_ULong i =3D len; i < pd_len; i++ ) =0A=
+#ifdef HAS_Cplusplus_const_cast=0A=
+ operator[](i) =3D const_cast<char*>(omni::empty_string);=0A=
+#else=0A=
operator[](i) =3D (char*) omni::empty_string;=0A=
+#endif=0A=
=0A=
if (len) {=0A=
// Allocate buffer on-demand. Either pd_data =3D=3D 0 =0A=
@@ -587,7 +616,11 @@=0A=
b[0] =3D (char*) ((omni::ptr_arith_t) 0x53515354U);=0A=
b[1] =3D (char*) l;=0A=
for (_CORBA_ULong index =3D 2; index < (nelems+2); index++)=0A=
+#ifdef HAS_Cplusplus_const_cast=0A=
+ b[index] =3D const_cast<char*>(omni::empty_string);=0A=
+#else=0A=
b[index] =3D (char*)omni::empty_string;=0A=
+#endif=0A=
return b+2;=0A=
}=0A=
=0A=
------_=_NextPart_000_01C1B31D.32ADA9B0--