Jump to content
  • Advertisement
Sign in to follow this  
nivlekio

Macros vs Messages

This topic is 3719 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, im just working on a win32 wrapper, and i am including some functionality to it like adding classes to manage the controls(listboxes, buttons, combo boxes etc) for dialogs . Ive been using the SendMessage() function with the messages eg "LB_ADDSTRING" and i have just noticed that microsoft also has macros for all the messages, LB_ADDSTRING has the macro int ListBox_AddStrind(). I was wondering why have two diffrent meathods to do the same thing? I know just by looking at the macros its alot eaiser to use since it requires alot less parameters, but apart from that are there any other diffrences? eg speed, realibility etc? Thanks for the help in advance :)

Share this post


Link to post
Share on other sites
Advertisement
Quote:

looking at the macros its alot eaiser to use


Thats the point. Macros are good for making a single line of code that is a pain to write out a lot easy eg MAX and MIN functions.

The preprocessor just copies and pastes so there is no performance benefit

Some would say inline functions are better but thats another lengthy debate

Share this post


Link to post
Share on other sites
try this:



#define MAX(a, b) ((a) > (b) ? (a) : (b))

int readInt(); // reads an int from somewhere

int main()
{
int x = MAX(readInt(), 5);
}


Do you still think that marcos are better than inline functions?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!