944,081 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1378
  • C++ RSS
Nov 25th, 2007
0

Macro conventions

Expand Post »
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:
C++ Syntax (Toggle Plain Text)
  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,
Similar Threads
Reputation Points: 15
Solved Threads: 5
Junior Poster in Training
phalaris_trip is offline Offline
91 posts
since Apr 2007
Nov 25th, 2007
0

Re: Macro conventions

Yes, leave the ; out of the macro definition.

Then things like if ( EVENT_RESIZE(event) == SUCCESS ) also work as well.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Nov 25th, 2007
0

Re: Macro conventions

Yes, of-course, that makes sense.. thanks
Reputation Points: 15
Solved Threads: 5
Junior Poster in Training
phalaris_trip is offline Offline
91 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: error C2664: 'strcpy' : cannot convert parameter 2 from 'const char' to 'const char *
Next Thread in C++ Forum Timeline: file IO and fuctions





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC