Donald Anderson, I've wondered if we could get some leverage by replacing the regex and sed expressions in the dist scripts with a real Python C parser (for example, pycparser?
The docs for pycparser indicate it's been used to write static code checkers, which seems related to this task. And more generally, we have magic shell scripts that figure out external prototypes based on pretty explicit assumptions on how a function is declared, and maybe something like pycparser would make things better.
A more focused change might be to extend the clang static analyzer to catch this error. See How to Write a Checker in 24 Hours, it's a discussion about how to extend clang's static analyzer with your own tests. I'm less excited about this change because I think I'm the only person regularly running the clang static checker and it requires a human to look at the output, I haven't found a way to automate it, so it would be harder to integrate this into our workflow.
Anyway, just thinking of ways we might get past creating adhoc scripts that need to be extended over time, since you're thinking about this as well.