Skip to content

dec_macros: always include ctype.h for FIELD_TFF - #1537

Closed
mlightcad wants to merge 1 commit into
LibreDWG:masterfrom
mlightcad:fix/ctype-include
Closed

mlightcad wants to merge 1 commit into
LibreDWG:masterfrom
mlightcad:fix/ctype-include

Conversation

@mlightcad

Copy link
Copy Markdown
Contributor

Summary

Fixes #1531.

FIELD_TFF uses isprint(), but ctype.h was only included when HAVE_CTYPE_H / _MSC_VER was set. That breaks C99 builds (notably emscripten) when autoconf leaves HAVE_CTYPE_H unset.

Change

Include <ctype.h> unconditionally.

Test plan

  • Configure/build with a toolchain that leaves HAVE_CTYPE_H undefined and confirm FIELD_TFF compiles

HAVE_CTYPE_H is often left unset in config.h even though ctype.h is ISO
C. C99 then rejects the implicit isprint() declaration used by
FIELD_TFF (notably under emscripten/WASM).

* src/dec_macros.h: Include <ctype.h> unconditionally.
@rurban

rurban commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

emscripten doesn't find the header in the probes? Does for me, with both emconfigure and cmake

@rurban rurban self-assigned this Nov 15, 2026
@rurban

rurban commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Thanks, applied to master. I cannot reproduce the missing HAVE_CTYPE_H: with emsdk 4.0.12 emconfigure ../configure --disable-bindings --disable-python CFLAGS=-std=c99 prints checking for ctype.h... yes and src/config.h has #define HAVE_CTYPE_H 1. CMake (CHECK_INCLUDE_FILE) sets it too. So we would like to fix the probe, not only work around it. Could you tell us how you build libredwg-web: the exact configure/cmake command line and emscripten version, whether you use your own config.h, and the checking for ctype.h lines of config.log (or the HAVE_CTYPE_H line in your config.h)?

rurban added a commit that referenced this pull request Nov 15, 2026
ctype.h is ISO C. FIELD_TFF uses isprint(), which C99 builds reject as an
implicit declaration when HAVE_CTYPE_H is not set in config.h.

From PR #1537 by mlightcad. Fixes #1531.
@rurban rurban closed this Nov 15, 2026
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.

dec_macros: FIELD_TFF needs ctype.h when HAVE_CTYPE_H is unset

2 participants