Skip to content

Conversation

@paulray
Copy link
Contributor

@paulray paulray commented Oct 20, 2025

A system upgrade caused me to compile PRESTO with gcc 15, which seems to strictly enforce ANSI C, so the old code in PRESTO that used K&R C declarations started causing errors.
I used this as an excuse to try Claude Code and had it do the conversion.
The result is this pull request. It was done by AI, so it needs a careful review and some testing.

paulray and others added 6 commits October 20, 2025 14:06
Updated function declarations from old-style K&R C to modern ANSI C
style in multiple source files for better compatibility with modern
compilers and improved code readability.

Files modified:
- include/fitsfile.h: Updated function prototypes
- src/fitsfile.c: Converted 21 functions
- src/hget.c: Converted 26 functions
- src/hput.c: Converted 19 functions
- src/imio.c: Converted 15 functions
- src/range_parse.c: Converted 6 functions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
This completes the K&R to ANSI C conversion by updating all header files
to match the function prototypes in the implementation files. Modern C
compilers (gcc 15+) require proper function prototypes in headers.

Changes:
- include/imio.h: Updated 14 function declarations with full parameter lists
- include/fitshead.h: Updated 40+ hget*/hput* and helper function declarations
- include/fitsfile.h: Added fitsheadsize declaration, updated imswap functions
- src/hget.c: Removed conflicting K&R forward declaration
- src/hput.c: Removed 4 K&R forward declarations of ksearch
- src/fitsfile.c: Removed K&R forward declaration of fitsheadsize
- src/accelsearch.c: Fixed function pointer types with proper signatures
- src/wapp_head_parse.c: Fixed forward declarations and include order
- src/readfile.c: Fixed function pointer array type declaration

Build now succeeds with gcc 15.1.0 on macOS with no errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
On macOS with gcc15 and gfortran from MacPorts, executables that link
both C and Fortran code were getting duplicate /opt/local/lib/libgcc
RPATH entries, causing dyld to abort with an error.

Changes:
- Restructured macOS-specific linker flags in meson.build
- Added -Wl,-no_warn_duplicate_libraries flag for macOS
- Added post-install script fix_rpath_duplicates.py to clean up any
  remaining duplicate RPATHs (defensive measure)

This fixes errors like:
  dyld[75722]: duplicate LC_RPATH '/opt/local/lib/libgcc' in prepfold

Tested on macOS 26.0 with gcc15 15.1.0 from MacPorts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@paulray
Copy link
Contributor Author

paulray commented Oct 20, 2025

OK, I have looked this over and tried it on both an Apple Silicon Mac (with an older gcc) and an x86 MacBook (with gcc15) and it compiles and works on both.

@paulray
Copy link
Contributor Author

paulray commented Oct 23, 2025

Thoughts on merging this?

@scottransom
Copy link
Owner

Yes! I'm almost certainly going to do it. I've just been traveling a ton and have been trying to catch up and I'm leaving again for another trip today! So maybe early next week? I did take a look at many of the changes and they look good. Thanks for doing this!

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.

2 participants