Hacker News new | ask | show | jobs
by kragen 5002 days ago
The advantage is smallest for things like that, which you'd put in a nameless enum. To my eyes, there's still a better signal-to-noise ratio in

    max_line = 512,
than in

    #define MAXLINE 512
but I agree that the difference is small. In some cases, your code is more readable if you can define more than one constant per line, and the difference becomes larger:

    min_x = 20,          min_y = 20,
    max_x = 8.5*72 - 20, max_y = 11*72 - 20,
Beyond that, non-anonymous enums have the additional advantages that you can define them closer to where they're used, and the debugger knows how to print them.
1 comments

the debugger knows how to print them.

I just want to emphasize this point, as this is the main advantage in my eyes.

It's a pretty big advantage when it applies, but it doesn't apply to the MAXLINE case, and it only applies when you're using a debugger. Which, for me, is very rarely.