On Mon, Mar 31, 2025 at 11:10:30PM -0400, Jeff King wrote: > On Mon, Mar 31, 2025 at 10:33:58PM -0400, Jeff King wrote: > > > That would be nice. I think we've discussed type safety for > > parse-options before, but IIRC none of the solutions were very > > satisfying. But this sounds like a relatively low-effort approach that > > buys us something, at least. I wonder if it could even be extended to > > use __builtin_types_compatible() on platforms that support it. > > So here's a slightly fancier version that uses the gcc builtin when it's > available: Thanks for these! I'd also like to spin this even further: right now we don't really care about the precision of the underlying integer types at all. While we could force all users to the same type via your mechanism, I think that'd ultimately be quite awkward. Another way would be to use one macro per underlying integer type, but that would quickly explode in scope. I'll instead try to extend the parse-options interface so that we track the precision of the underlying integer and then produce an error when the parsed integer exceeds that precision. I'll send a patch series later this week. Patrick