Fix warning for when 2nd `iconv()` argument is const
This commit is contained in:
parent
495e9b2fa0
commit
86f231184b
|
@ -514,6 +514,9 @@ endforeach()
|
|||
|
||||
if(ICONV_FOUND)
|
||||
add_definitions(-DHAVE_ICONV)
|
||||
if(ICONV_SECOND_ARGUMENT_IS_CONST)
|
||||
add_definitions(-DICONV_SECOND_ARGUMENT_IS_CONST)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# if(MINGW)
|
||||
|
|
|
@ -22,8 +22,7 @@ if(ICONV_FOUND AND NOT DEFINED ICONV_SECOND_ARGUMENT_IS_CONST)
|
|||
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIRS})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
|
||||
|
||||
check_c_source_compiles(
|
||||
"
|
||||
check_c_source_compiles("
|
||||
#include <iconv.h>
|
||||
int main ()
|
||||
{
|
||||
|
@ -34,7 +33,10 @@ if(ICONV_FOUND AND NOT DEFINED ICONV_SECOND_ARGUMENT_IS_CONST)
|
|||
size_t olen = 0;
|
||||
iconv (conv, &in, &ilen, &out, &olen);
|
||||
return 0;
|
||||
}" ICONV_SECOND_ARGUMENT_IS_CONST)
|
||||
}"
|
||||
ICONV_SECOND_ARGUMENT_IS_CONST
|
||||
FAIL_REGEX "incompatible pointer type"
|
||||
FAIL_REGEX "discards qualifiers in nested pointer types")
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
|
|
|
@ -1034,7 +1034,11 @@ to_utf8 (const char * in, size_t inlen)
|
|||
|
||||
for (i=0; !ret && i<encoding_count; ++i)
|
||||
{
|
||||
#ifdef ICONV_SECOND_ARGUMENT_IS_CONST
|
||||
const char * inbuf = in;
|
||||
#else
|
||||
char * inbuf = (char*) in;
|
||||
#endif
|
||||
char * outbuf = out;
|
||||
size_t inbytesleft = inlen;
|
||||
size_t outbytesleft = buflen;
|
||||
|
|
Loading…
Reference in New Issue