Macro conventions

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2007
Posts: 84
Reputation: phalaris_trip is an unknown quantity at this point 
Solved Threads: 5
phalaris_trip's Avatar
phalaris_trip phalaris_trip is offline Offline
Junior Poster in Training

Macro conventions

 
0
  #1
Nov 25th, 2007
I know this is a slightly esoteric question, but I'm just curious how you guys define your function macros. Do you put a semicolon at the end or not?

For example:
  1. #define EVENT_RESIZE(_event) ::SDL::HandleEventResize(_event, hScreen, fnSDLKey);
  2.  
  3. // or
  4.  
  5. #define EVENT_RESIZE(_event) ::SDL::HandleEventResize(_event, hScreen, fnSDLKey)

In the first case, the advantage is that you don't have to type a semicolon in the actual code
EVENT_RESIZE(event)
which mean it's immediately obvious that it's a macro. I know Microsoft like to do it like this sometimes..

The second scenario requires a semicolon in the actual code
EVENT_RESIZE(event);
which means it behaves more like a standard function..

Anyway I know this is a kind of stupid question, but we have to design a bunch of SDL macros to standardise our code templates and I'm just curious which is the accepted convention.

Cheers,
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Macro conventions

 
0
  #2
Nov 25th, 2007
Yes, leave the ; out of the macro definition.

Then things like if ( EVENT_RESIZE(event) == SUCCESS ) also work as well.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 84
Reputation: phalaris_trip is an unknown quantity at this point 
Solved Threads: 5
phalaris_trip's Avatar
phalaris_trip phalaris_trip is offline Offline
Junior Poster in Training

Re: Macro conventions

 
0
  #3
Nov 25th, 2007
Yes, of-course, that makes sense.. thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC