Re: DBI Driver.xst and DBD::cego
Since the only place 'plural' is used is the statement immediately after the assignment, it is much simpler and perfectly safe to use const char *plural = ... than to futz around with the myp array as in the second patch (or to cast away constness as in the first patch). On Mon, May 27, 2013 at 8:16 AM, Kurt Jaeger wrote: > Hi! > > Tim wrote: > > On Sun, May 26, 2013 at 08:13:58PM +0200, Kurt Jaeger wrote: > > > https://rt.cpan.org/Ticket/Display.html?id=84285 > > > > error: invalid conversion from 'const char*' to 'char*' > > > > I'm surprised the compiler treats this as an error, it's normally a > warning. > > > -char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? "" : "s"; > > +char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? (char*)"" : > (char*)"s"; > > clang++ is more strict 8-} > > > > Can someone have a look at it ? Is that patch the right way to do it ? > > > > It would be better to put the const on the declaration in this case. > I.e.: > > > > -char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? "" : "s"; > > +const char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? "" : "s"; > > > > but that may trigger other errors/warnings in later code which will need > > attending to. (Same goes for the other hunk in the patch.) > > > > Could you give that a go? > > Have you seen my second attempt ? It's going along the clang line > and seems much cleaner. > > -- > p...@opsec.eu+49 171 3101372 7 years to > go ! > -- Jonathan Leffler #include Guardian of DBD::Informix - v2013.0521 - http://dbi.perl.org "Blessed are we who can laugh at ourselves, for we shall never cease to be amused."
Re: DBI Driver.xst and DBD::cego
Hi! Tim wrote: > On Sun, May 26, 2013 at 08:13:58PM +0200, Kurt Jaeger wrote: > > https://rt.cpan.org/Ticket/Display.html?id=84285 > > error: invalid conversion from 'const char*' to 'char*' > > I'm surprised the compiler treats this as an error, it's normally a warning. > -char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? "" : "s"; > +char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? (char*)"" : > (char*)"s"; clang++ is more strict 8-} > > Can someone have a look at it ? Is that patch the right way to do it ? > > It would be better to put the const on the declaration in this case. I.e.: > > -char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? "" : "s"; > +const char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? "" : "s"; > > but that may trigger other errors/warnings in later code which will need > attending to. (Same goes for the other hunk in the patch.) > > Could you give that a go? Have you seen my second attempt ? It's going along the clang line and seems much cleaner. -- p...@opsec.eu+49 171 3101372 7 years to go !
Re: DBI Driver.xst and DBD::cego
Hi Kurt. On Sun, May 26, 2013 at 08:13:58PM +0200, Kurt Jaeger wrote: > https://rt.cpan.org/Ticket/Display.html?id=84285 error: invalid conversion from 'const char*' to 'char*' I'm surprised the compiler treats this as an error, it's normally a warning. -char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? "" : "s"; +char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? (char*)"" : (char*)"s"; > Can someone have a look at it ? Is that patch the right way to do it ? It would be better to put the const on the declaration in this case. I.e.: -char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? "" : "s"; +const char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? "" : "s"; but that may trigger other errors/warnings in later code which will need attending to. (Same goes for the other hunk in the patch.) Could you give that a go? Tim.