It is totally use choice, Some may prefer one or the other for stylistic reasons, but before making any choice where to use " enum " and where " macro" plz keep these in mind.
It is best to use enums when some variable can hold one of multiple values which can be given names. for example. (color, day, months etc) enum color { RED, BLUE, YELLOW, // etc };
You can use macro where you doing same set of things again an again. for example . debug prints. for that just define a macro for the debug print and use. some constant value. int buff [ MAX_LEN ] // define MAX_LEN as a macro.
One difference is that macros allow you to control the integral type of related constants. But an enum will use an int. ie. #define X 100L enum { Y = 100L };
printf("%ld\n", X); printf("%d\n", Y); /* Y has int type */
Macro is a preprocessor where as enum is not.
#define MY_STRUCT typedef struct{ ... ... } my_struct;
Above code is giving me error (MY_STRUCT) is not working as expected, Looks that some silly mistake, please point out as I have wasted many hours?
Sorry for hiding my identity?