Rediscovering Macros with MC++
I've been coding primarily in C# for a couple of years now. Up until recently it had been almost a year since I coded any real C++ code. Now that I am using MC++ at home I am starting to get back in the habbit and last night I rediscovered macros (you'd be amazed at what you forget to use after a year or so). I've found that they are very useful for repetitive argument validation code. As below
#define EARG_NONNULL(x) \
if ( nullptr == x ) throw gcnew ArgumentNullException(L#x)
I realize that macros can be dangerouns when you abuse them. But people abuse them for a reason ... they're useful.
Some of my friends have told me that Code Snippets in Whidbey are another easy solution to the repetitve nature of coding items like argument validation. I am going to look at those and I'll add a blog entry about them as well in the next few days.