# Macros vs Messages

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

## 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 on other sites
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 on other sites
try this:

#define MAX(a, b) ((a) > (b) ? (a) : (b))int readInt(); // reads an int from somewhereint main(){    int x = MAX(readInt(), 5);}

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

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
18

• 11
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631420
• Total Posts
2999990
×