Haha! Hodgman you are my hero! That works great! And seems way more elegant than using boost. Works perfect with vs2005 express.
Thanks again bud!
[Solved] C++ Macro question...
I would recommend using BOOST_PP_ it's much more flexible.
You are going to want a fair few elements in the sequence though to make it worth your while. Unless of course the code that you are using in the callback macro gets more complicated and it becomes a hassle / maintenance issue to keep typing it over and again.
// local callback macro to generate a function map, elem is a tuple of the form (id prefix, function name)#define LOCAL_MACRO_WITH_A_MEANINGFUL_NAME(r, data, elem) mFuncMap[BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, elem), Id)] = &BOOST_PP_CAT(func, BOOST_PP_TUPLE_ELEM(2, 1, elem));// generate the function map from a sequence of tuples, calling LOCAL_MACRO_WITH_A_MEANINGFUL_NAME// on each element in the sequenceBOOST_PP_SEQ_FOR_EACH(LOCAL_MACRO_WITH_A_MEANINGFUL_NAME, _, ((mesh, Mesh)) ((particleEffect, ParticleEffect)) ((rigidBody, RigidBody)))// don't pollute the global namespace#undef LOCAL_MACRO_WITH_A_MEANINGFUL_NAME
You are going to want a fair few elements in the sequence though to make it worth your while. Unless of course the code that you are using in the callback macro gets more complicated and it becomes a hassle / maintenance issue to keep typing it over and again.
Quote:You are going to want a fair few elements in the sequence though to make it worth your while
And why would having a large list of names be a problem with Hodgman's method? I define the list ONCE, then I can use it with ANY macro. Keep in mind the onlything I need is the NAME of the component (upper and lower case versions are nice to have too). Although with Hodgman's method it seems like it would be trivial to pass additional information to the macros if I ever needed too.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement