Function for macros (Switch case)

Status
Not open for further replies.

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
What is the function for this macros below? What's the advantage for this?

Code:
#define MYCASE(_item,_id) \ 
   case _id: \ 
     _item##_##_id=_id;\ 
   break 

  switch(x) { 
      MYCASE(widget,23); 
  }

How can we add another..
- MYCASE(widget,24);
- MYCASE(widget,35);
- MYCASE(high,168);

and can we add more case in one MYCASE? Can you please rewrite the program and show it?

Thank You.

ThanK You
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…