Macros vs Messages

Started by
1 comment, last by rozz666 15 years, 9 months ago
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 :)
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
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?

This topic is closed to new replies.

Advertisement