[cairo] return type of cairo_status_to_string ()

Daniel Goldman dagoldman at yahoo.com
Tue Aug 17 22:33:47 PDT 2010

> > And what about the analogous function "char  *strerror (int errnum)"?

> Old functions have not been modified precisely  because people are assigning 
>the results to a char* rather than a const  char*.
> Since Cairo is "new" and there is no legacy code trying to call  this function, 
>this excuse is not needed.
> > But the man page says  "This string must not be modified by the 
> That is  *precisely* the purpose of making the return value "const char*", it 
>tells the  compiler that the program should not attempt to modify the returned 

So you're saying strcpy () and strcat () could be modified to accept const char 
* parameters without breaking old code. But changing the return type of strerror 
() would break legacy code. It makes sense. Some of the strerror () man pages 
even support what you are saying by calling it a "bug" that the strerror () 
return type is not const char * - For example: 

I still can't imagine why someone would try to modify the string, such as char 
*error_str = func (); error_str [0] = 'x'; so the precaution in this case seems 
unnecessary. I'm used to taking responsibility and not having the software 
needlessly babysit me. But I've already adapted and moved on and learned some. 


More information about the cairo mailing list