perl - Why do XS subs use const char *? -
a lot of perl xs code uses const char * return value of xs sub never char *. example:
const char * version(...) code: retval = chromaprint_get_version(); output: retval code xs-fun
can explain why const preferred? in testing, returned scalar modifiable whether const used or not.
it's clarity. chromaprint_get_version function returns const char *, xsub should defined const char * return type well. if have @ built-in typemap, doesn't make difference whether use const char *, char *, or unsigned char *. use t_pv typemap. in cases, xsub return sv containing copy of c string, modifiable.