954,219 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Macro conventions

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:

#define EVENT_RESIZE(_event) ::SDL::HandleEventResize(_event, hScreen, fnSDLKey);

// or

#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,

phalaris_trip
Junior Poster in Training
91 posts since Apr 2007
Reputation Points: 15
Solved Threads: 5
 

Yes, leave the ; out of the macro definition.

Then things like if ( EVENT_RESIZE(event) == SUCCESS )
also work as well.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

Yes, of-course, that makes sense.. thanks

phalaris_trip
Junior Poster in Training
91 posts since Apr 2007
Reputation Points: 15
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You