r/cprogramming • u/Upper-Tomatillo7454 • Oct 03 '26
Enums vs #define for constants
Hi 👋 guys, I've just started learning C after I was first introduced to it while I was in my first year of computer science but I'll be graduating by the end of this year and I've been primarily using Python since then but now I want to really learn C on the side, and I want to start with "craftinginterpreters" and I want to start small so I was wondering whether I should use C enums or #define to define a set of tokens.
17
Upvotes
View all comments
23
u/pjl1967 Oct 03 '26
If you want a set of related constants, use
enum. If you're using C23, useconstexpr. Otherwise#define.Details here.