-4
#define LOG_TYPE_LIST      \                                                                                                                
    LOG_TYPE( INFO )     \                                                                                 
    LOG_TYPE( WARNING )  \                                                                                     
    LOG_TYPE( ERROR )    \        

typedef enum
{
#define LOG_TYPE(x) x,
LOG_TYPE_LIST
#undef LOG_TYPE
} LogType;

This is in C++. I know that the first section is a multiline macro, but the second section seems like a mystery to me.

  • 3
    https://en.wikipedia.org/wiki/X_macro – 463035818_is_not_an_ai Aug 07 '23 at 16:59
  • @463035818_is_not_an_ai There are likely uses of LOG_TYPE_LIST elsewhere that work together with the enum. That's the point of X-macros. – n. m. could be an AI Aug 07 '23 at 17:09
  • The second part expands to `typedef enum { INFO, WARNING, ERROR, } LogType;` By itself that doesn't justify the macro use. As said above, the point is that somewhere else in your code there should be a different use of `LOG_TYPE_LIST` with a different expansion. – john Aug 07 '23 at 18:21

0 Answers0