Fix K&R in DBbound.c.#487
Closed
gonsolo wants to merge 1 commit into
Closed
Conversation
RTimothyEdwards
approved these changes
Jun 9, 2026
RTimothyEdwards
left a comment
Owner
There was a problem hiding this comment.
One of about a thousand such updates that needs to be made. Thanks for the PR.
Owner
|
Pulled and merged to the repository at opencircuitdesign.com (github mirror will be updated overnight). |
This was referenced Jun 9, 2026
Contributor
Author
1162, to be precise. 😉 |
gonsolo
added a commit
to gonsolo/magic
that referenced
this pull request
Jun 9, 2026
Convert 1162 old-style (K&R) function definitions to modern ANSI C prototypes across the tree, following the pattern of PR RTimothyEdwards#487, and remove the -Wno-implicit-int flag that was suppressing the related warnings in the emscripten target. GCC 16 defaults to C23, where "()" means "(void)" rather than "unspecified arguments", which broke the build independently of the K&R conversion. Add -std=gnu17 (in the gcc SHLIB_CFLAGS block and the emscripten target of scripts/configure[.in]) to restore C17 semantics so the many remaining legacy "()" declarations keep compiling. The emscripten/clang toolchain also defaults to C23 and silently ignores the "--std=" long form some CI scripts pass, so it needs the single-dash -std=gnu17 explicitly. Fix the errors the ANSI conversion then exposed: - Type forward/header declarations that conflicted with the now-typed definitions. Under C, an empty "()" declaration is incompatible with a prototype whose parameters undergo default promotion (bool, float), so these had to be given explicit signatures. The database module's declarations live in the generated header database.h, so these changes are made in its source template database.h.in (editing the generated database.h directly is lost on a clean build). - Add struct-tag forward declarations (MagWindow, GrGlyph, TxCommand, NLNetList, cellUE, struct inarg) where the type was not visible at the point of use, including to break circular header includes. - Revert over-typed generic callback pointers (WindAddClient, WindSearch, GrLockPtr/GrUnlockPtr) back to "()": their callbacks have intentionally varying return types and they take no promotable scalar arguments. - Fix genuine latent mismatches surfaced by stricter checking: "extern int wind*Cmd()" declarations that should be void, the DebugSet bool/int parameter mismatch, the typed func pointers in CmdCD and PlowRules3, and comparator/callback casts for qsort, extEnumTilePerim, and the Tk/TOGL lock pointers. Result: the tree compiles cleanly under GCC 16 and tclmagic.so links and loads successfully. Verification ------------ - Clean-from-scratch native build (make clean + make -j -k): 0 errors, exit 0. The only warnings are 18 benign -Wdiscarded-qualifiers (const pointers passed to the newly-typed prototypes, which do not declare const; the callees do not mutate the data). - Re-verified with bool defined as _Bool (-DHAVE_STDBOOL_H=1, matching the CI runners where stdbool.h is detected): 0 errors. Locally autoconf 2.69's C99 stdbool test fails under GCC 16 so bool falls back to signed char; both configurations now build. - WASM build reproduced locally with emscripten (emconfigure ./configure --host=asmjs-unknown-emscripten ... ; emmake make depend modules libs techs mains): 0 errors, produces magic.js and magic.wasm. - tclmagic.so loads and magic::initialize -dnull -noconsole succeeds. - Functional smoke test against the generated scmos.tech exercised the most heavily-converted files, all producing correct results: * tech load (DBtech*.c) * paint poly/metal1/pcontact, with pcontact correctly forming polycontact (DBpaint.c, DBtpaint.c, DBtcontact.c) * drc check (DRCbasic.c, DRCtech.c) * extract all -> realtest.ext (ExtBasic.c/ExtMain.c, including the extEnumTilePerim callback cast) * save -> reload disk round-trip preserving all layer types (DBio.c read and write) Not covered by the smoke test (compiled and loaded, but not executed): the routers (grouter/mzrouter/garouter/irouter), GDS/CIF/LEF I/O, plotting, and 3D. A valid-but-wrong type in one of those untested paths would not have been caught at runtime, though the clean build rules out most mis-typings (which surface as compile errors). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Intubun
pushed a commit
to Intubun/magic
that referenced
this pull request
Jun 10, 2026
… the formatting used for other subroutines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.