[Prototype replied while I was writing this, but I'll go ahead and post it just in case you find something here useful ?]
Some IDEs that support C/C++ include a feature that allows you to examine the preprocessor output. If you have such a feature available, you might find it informative to examine the preprocessor output for your 'Used as' example. I think your description of what's going on is probably accurate or close to it, but you might find actually seeing the preprocessor output to be illuminating.
Quote
Do you basically use the macro to save writing much more repeated text than you would have to write if you didn't use it?
I would guess that's the motivation in this particular case, yes.
Quote
Is this use correct? In The C ++ Programming Language, Bjarne Stroustrup, apart from practically not addressing the issue, seems very contrary to the use of macros.
Preprocessor macros have some disadvantages and associated pitfalls that are discussed frequently. For example, they don't obey scope, which can cause issues in some circumstances.
My casual observation is that over time the conventional wisdom has increasingly become to favor non-preprocessor features over using the preprocessor when it's possible or at least reasonable to do so. This has become easier to do as new features have been added to C/C++. That doesn't necessarily mean you should never use macros - just that other options should arguably be considered first.
There may be cases where for whatever reason (e.g. there being syntactical elements involved, as in your example) it's not obvious how to reduce boilerplate without using the preprocessor. As for the particular example you posted, without knowing more about the code I can't really say if there are better solutions (although some might argue just writing it out manually each time would be preferable). Looking at the code, some possible alternative solutions spring to mind, but without more context I can't say if they'd actually work or not.
The last thing I'll say is:
Quote
What I understand is that using macros first sets the header or signature of a function (GetTransitionTable), and inside, defines a static variable TRANSITION_TABLE, which is an array. With the following macro, TRANSITION_ENTRY, fill in the array, I suppose doing an implicit construction of objects, and converting the parameters into the objects expected by the potential object of each element of the array. Finally add a null element at the end.
You may already understand this, but just for clarity I'll point out that the macro doesn't really 'do' anything itself. That is, it's not defining or constructing or converting arrays or object or anything like that. All the preprocessor does (to the best of my knowledge at least) is manipulate text.