Hi, Julien Nadeau a écrit : > On Sun, Oct 11, 2009 at 10:02:25AM +0200, Olivier Boudeville wrote: > >> Hello, >> >> In Agar 1.3.4, file agar/core/string_compat.h, line 245, the 'return >> ((char *)s);' statement casts away constness (parameter was 'const char >> *s'), and breaks in the user code. I guess that string s should not be >> declared as const. >> > > What compiler are you using? Can you try un-inling the function (i.e., > moving it over to string_compat.c)? > I was using gcc 4.3.3 on GNU/Linux with quite a lot of warnings enabled. Yes, it could be set back in the implementation file, however returning a const char * could also be a good choice, wherever it is defined. > This is the standard strcasestr() copied from BSD libc; it does not modify > the string and not declaring the s parameter as const would break other > functions using it. Hopefully, de-inlining the function will prevent this > warning. > OK, initially I did not notice that the input string was left untouched. I guess that *returning* a const char * could be a better fix, unless some calling code actually modifies the returned substring. Not a big deal anyway.
Best regards, Olivier. > > > _______________________________________________ Agar mailing list [email protected] http://libagar.org/lists.html
