News for hackers. Stuff that matters.
Re:To become a good C programmer (2011) by boomlinde on Saturday February 15, 2020 @08:56AM (#22335300)
Backward compatibility. Your example would impose additional constraints on the %d specifier that would likely break existing code. What if you want an int immediately followed by literal ”64”?
Re:To become a good C programmer (2011) by earenndil on Saturday February 15, 2020 @06:26PM (#22338763)
Oops, I typoed. I said 'new *printf functions'; the example was supposed to be 'printf2("int64: %d64", x)'
Re:To become a good C programmer (2011) by boomlinde on Monday February 17, 2020 @05:24PM (#22351464)
I see! That would make more sense, but I still think the inttypes.h macros are a sufficient solution. Implementers and standards influencing users probably aren't too keen on another formatting language when you can implement it as macros that only take another few characters to use.

    printf2("int64: %d64", x);
for example isn't significantly shorter than

    printf("int64: %" PRId64, x);
Perhaps it's easier to read, but when you have to support both, and you're more likely to run into the latter than the former anyway, I think it just adds cognitive overhead to have to consider which formatting language is being used.