Skip to content

NetBSD: iconv(3) prototype changed in NetBSD 10 #20089

Closed

Description

@0-wiz-0

Description

Compiling the iconv module on NetBSD 11.99.3 fails:

/scratch/converters/php-iconv/work/php-8.4.13/ext/iconv/iconv.c: In function '_php_iconv_appendl':
/scratch/converters/php-iconv/work/php-8.4.13/ext/iconv/iconv.c:370:39: error: passing argument 2 of 'iconv' from incompatible pointer type [-Wincompatible-pointer-types]
  370 |                         if (iconv(cd, (ICONV_CONST char **)&in_p, &in_left, (char **) &out_p, &out_left) == (size_t)-1) {
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                       |
      |                                       const char **

(and many more similar errors) because NetBSD changed their iconv(3) prototype in NetBSD 10 to follow
what other operating systems are doing.
The following patch works for me:

--- iconv.c.orig        2025-10-07 08:26:27.242448383 +0000
+++ iconv.c
@@ -44,6 +44,10 @@
 #endif

 #if defined(__NetBSD__)
+#include <sys/param.h>
+#endif
+
+#if defined(__NetBSD__) && (__NetBSD_Version__ < 1000000000)
 // unfortunately, netbsd has still the old non posix conformant signature
 // libiconv tends to match the eventual system's iconv too.
 #define ICONV_CONST const

The comment would need to be changed too of course, I'll leave that up to you.

PHP Version

php 8.4.13

Operating System

NetBSD

Activity

  1. devnexen commented on Oct 7, 2025

    @devnexen
    Member

    quick question, I ve not touched netbsd since couple of months however I believe there is the system's libiconv and the pkgsrc one correct ? If that s the case which one are you using ? I may have a look later otherwise.

  2. 0-wiz-0 commented on Oct 7, 2025

    @0-wiz-0
    Author

    That's with the native iconv(3) implementation.
    From NetBSD 10 onwards, they both use the same interface.

  3. self-assigned this
    on Oct 7, 2025
  4. NattyNarwhal commented on Oct 7, 2025

    @NattyNarwhal
    Member

    If I may toot my own horn, GH-16847 should handle this more gracefully.

  5. nwellnhof commented on Oct 8, 2025

    @nwellnhof

    Another simple approach is to remove the "iconv const check" and always cast the argument to void * which will then be implicitly converted to either char ** or const char **.

  6. petk commented on Oct 15, 2025

    @petk
    Member

    Same warning happens also on Solaris 11.4. Solaris 10 and some illumos-based distributions need the const in there.

  7. NattyNarwhal commented on Oct 29, 2025

    @NattyNarwhal
    Member

    GH-20247 is merged and should fix this. Reopen if this still needs work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions