Subject: | Compiler warnings with clang on freebsd |
Compiling with clang on freebsd, noticed the following compiler warnings
The following compiler warning is a problem:
XSConstructor.xs:127:19: warning: incompatible pointer types passing 'I32 *' (aka 'long *') to parameter of type 'STRLEN *' (aka 'unsigned int *') [-Wincompatible-pointer-types]
keyname = SvPV(attr, keylen);
^
Make keylen a STRLEN not an I32 to avoid crashes on 64 bit machines.
This module might help:
https://metacpan.org/pod/distribution/XS-Check/lib/XS/Check.pod
This is strange:
XSConstructor.xs:141:17: warning: initializing 'char *const' with an expression of type 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
char* const klass = sv_reftype(SvRV(object), 1);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
char * const klass means that the value of "klass" itself is constant, not the thing it's pointing to, which is what you should have here.
I don't know if this is helpful but it goes into more detail about the STRLEN issue:
https://www.lemoda.net/perl/perl-xs-cpan-testers/index.html