Skip to content

common: support win-iconv's const iconv() prototype - #9

Merged
lemenkov merged 1 commit into
masterfrom
windows-iconv-const
Jul 25, 2026
Merged

common: support win-iconv's const iconv() prototype#9
lemenkov merged 1 commit into
masterfrom
windows-iconv-const

Conversation

@lemenkov

Copy link
Copy Markdown
Owner

A small, self-contained portability fix that unblocks cross-compiling the protocol core with Fedora's mingw-w64 toolchain. Split out ahead of the ODBC-shim Windows port (Phase 2) since it's independent.

The problem

iconv()'s second argument is char ** on glibc and GNU libiconv, but const char ** on win-iconv (the POSIX/SysV signature) — which is what Fedora's mingw stack (mingw64-win-iconv) ships. charset.c hard-coded char *inbuf, so it compiled fine against the GNU libiconv used by the MSYS2 CI leg but failed (-Wincompatible-pointer-types) against win-iconv.

This matters beyond local tooling: any future Fedora mingw package of SeerODBC would link win-iconv and hit the same wall.

The fix

Detect the prototype at configure time — a -Werror cc.compiles() probe (the autotools ICONV_CONST idiom) — and type charset.c's input pointer through the resulting SEER_ICONV_CONST macro: const for win-iconv, empty for glibc/GNU libiconv. Warning-clean under either, no runtime change.

Verification

  • Fedora mingw-w64 cross-build: full protocol core now links (previously failed at charset.c).
  • Native Linux (glibc): unchanged — probe detects non-const, offline suite 9/0/4, live 11g integration OK.
  • MSYS2/macOS unaffected (GNU libiconv / macOS iconv both non-const, same path as before).

🤖 Generated with Claude Code

iconv()'s second argument is 'char **' on glibc and GNU libiconv, but
'const char **' on win-iconv (the POSIX/SysV signature) - which is what
Fedora's mingw stack ships. charset.c hard-coded 'char *', so it failed
to compile (-Wincompatible-pointer-types) against win-iconv even though
it built fine against the GNU libiconv used by the MSYS2 CI leg.

Detect the prototype at configure time (a -Werror cc.compiles() probe,
the autotools ICONV_CONST idiom) and type charset.c's input pointer
through the resulting SEER_ICONV_CONST macro - 'const' for win-iconv,
empty for glibc/GNU libiconv - so it is warning-clean under either.

This makes the protocol core cross-compile cleanly with the Fedora
mingw-w64 toolchain (relevant both for local Windows-port iteration and
for any future Fedora mingw package of SeerODBC), with no change on the
existing Linux/macOS/MSYS2 builds.

Verified: full mingw cross-build links; native Linux unchanged (offline
9/0/4, live 11g integration OK).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
@lemenkov
lemenkov merged commit c1396d7 into master Jul 25, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant