bug-ddd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ddd/MString.h problems in 3.3 with Solaris C++ compiler, liberty ins


From: Arnaud Desitter
Subject: Re: ddd/MString.h problems in 3.3 with Solaris C++ compiler, liberty install problems
Date: Thu, 22 Feb 2001 17:32:03 +0000 ()

Hi,

Please try:

> >         _mstring(text ? XmStringCreateLtoR((char *)text, (char*)charset) : 
> > 0)
instead of:
> >         _mstring(text ? XmStringCreateLtoR((char *)text, charset) : 0)

That should help.
Note that it would be better to use "const_cast<char*>".

Cheers,
Arnaud

> 
> Hi!
> 
> bug-ddd@thewrittenword.com writes:
> 
> > ddd/MString.h has:
> > 
> > public:
> >     // Constructors
> >     MString(const char *text = "",
> >             XmStringCharSet charset = MSTRING_DEFAULT_CHARSET):
> >         _mstring(text ? XmStringCreateLtoR((char *)text, charset) : 0)
> >     {
> >         assert(OK());
> >     }
> > 
> > #if 0
> >     MString(char *text,
> >             XmStringCharSet charset = MSTRING_DEFAULT_CHARSET):
> >         _mstring(text ? XmStringCreateLtoR(text, charset) : 0)
> >     {
> >         assert(OK());
> >     }
> > #endif
> > 
> > The Sun C++ compiler (5.0 and 5.2) complains with:
> >   CC -DHAVE_CONFIG_H -I. -I. -I. -I./.. -I/opt/TWWfsw/xpm/include
> >   -I/usr/dt/include -I/usr/openwin/include
> >   -I/opt/TWWfsw/readline4/include   -DNDEBUG -xs  -xO2 -xtarget=generic
> >   -xarch=v8    -c ddd.C
> >   "MString.h", line 57: Error: Formal argument text of type char* in
> >   call to XmStringCreateLtoR(char*, char*) is being passed const char*.
> > 
> > Why was the constructor changed? Patch below to revert. Incidentally,
> > neither G++ 2.95.2 nor IRIX C++ 7.3.1m and 7.3.1.2m complain.
> 
> String constants in C++ are now of type `const char[]', so I must care
> about const correctness in DDD code.  The change was made to avoid
> lots of warnings on compilers that already treat string constants as
> read-only.  For GCC, this is (still) optional; try compiling with `gcc
> -Wwrite-strings'.
> 
> In this particular case, the Sun C++ compiler is wrong: the `text'
> argument to XmStringCreateLtoR(char*, char*) is explicitly casted to
> `char *', so I cannot see what's wrong here.  If you find a way to
> make both the Sun C++ compiler happy and not to generate any warnings
> with `gcc -Wwrite-strings', I'll be happy to apply it.
> 
> Thanks and best wishes,
> 
> Andreas
> 
> -- 
> Andreas Zeller     Universitaet Passau
>                    http://www.fmi.uni-passau.de/st/staff/zeller/
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]