[preprocessor]:issues with expansion.
hello all: I have the following code: #define REGISTER_MODULE(module)(\ #ifdef BOOST_PP_EQUAL(BOOST_PP_LIST_SIZE(MODULES), 0)\ //there are currently no modules in the list. #define MODULES((module), BOOST_PP_NIL) #else BOOST_PP_LIST_APPEND(MODULES, module)\ #endif ) I am somewhat of a newb at preprocessor magic, so any advice would be useful. For whatever reason this translates out to 'module)' when I try to compile it with -E -P. The idea is that it will add to the modules list (assuming the modules list exists) the module to be registered, which should just be a type. Thanks, -- Take care, Ty http://tds-solutions.net The aspen project: a barebones light-weight mud engine: http://code.google.com/p/aspenmud He that will not reason is a bigot; he that cannot reason is a fool; he that dares not reason is a slave.
On Wed, Dec 19, 2012 at 3:58 PM, Littlefield, Tyler
hello all: I have the following code: #define REGISTER_MODULE(module)(\ #ifdef BOOST_PP_EQUAL(BOOST_PP_LIST_**SIZE(MODULES), 0)\ //there are currently no modules in the list. #define MODULES((module), BOOST_PP_NIL) #else BOOST_PP_LIST_APPEND(MODULES, module)\ #endif )
I am somewhat of a newb at preprocessor magic, so any advice would be useful. For whatever reason this translates out to 'module)' when I try to compile it with -E -P. The idea is that it will add to the modules list (assuming the modules list exists) the module to be registered, which should just be a type. Thanks,
Someone can correct me here, but I believe you can't use preprocessor directives (#define, #if, etc.) within a macro definition, and, well, who knows what'll happen if you try :/ - Jeff
Date: Wed, 19 Dec 2012 20:13:23 -0800 From: jeffrey.hellrung@gmail.com To: boost-users@lists.boost.org Subject: Re: [Boost-users] [preprocessor]:issues with expansion.
On Wed, Dec 19, 2012 at 3:58 PM, Littlefield, Tyler
mailto:tyler@tysdomain.com> wrote: hello all: I have the following code: #define REGISTER_MODULE(module)(\ #ifdef BOOST_PP_EQUAL(BOOST_PP_LIST_SIZE(MODULES), 0)\ //there are currently no modules in the list. #define MODULES((module), BOOST_PP_NIL) #else BOOST_PP_LIST_APPEND(MODULES, module)\ #endif ) I am somewhat of a newb at preprocessor magic, so any advice would be useful. For whatever reason this translates out to 'module)' when I try to compile it with -E -P. The idea is that it will add to the modules list (assuming the modules list exists) the module to be registered, which should just be a type. Thanks,
Someone can correct me here, but I believe you can't use preprocessor directives (#define, #if, etc.) within a macro definition, and, well, who knows what'll happen if you try :/
- Jeff
Right, and to address your desired use case a little more specifically, I don't think you can store state in the preprocessor in between macro invocations (if I'm wrong, please correct me, I would find such an ability very useful as well). Regards, Nate
hello: Thanks for the info. What you said makes sense, I should've thought more before I went with it. Essentially here's what I'm trying to do--perhaps someone knows a better way to do this. Right now when I install a module in this system I'm working on, I have to add a #include to the top, and then something like RegisterModule<TileEngine>(); or something similar. I wanted a way to do something like call REGISTER_MODULE from the TileEngine.h so that it would be dynamically added in at compile-time, rather than having to hard-code the includes and registrations into the system. If there's a way with boost to do this at compile-time so that there is no need to hard-code it (excluding shared libraries), I'd apreciate any information. Thanks, On 12/19/2012 11:47 PM, Nathan Ridge wrote:
Date: Wed, 19 Dec 2012 20:13:23 -0800 From: jeffrey.hellrung@gmail.com To: boost-users@lists.boost.org Subject: Re: [Boost-users] [preprocessor]:issues with expansion.
On Wed, Dec 19, 2012 at 3:58 PM, Littlefield, Tyler
mailto:tyler@tysdomain.com> wrote: hello all: I have the following code: #define REGISTER_MODULE(module)(\ #ifdef BOOST_PP_EQUAL(BOOST_PP_LIST_SIZE(MODULES), 0)\ //there are currently no modules in the list. #define MODULES((module), BOOST_PP_NIL) #else BOOST_PP_LIST_APPEND(MODULES, module)\ #endif ) I am somewhat of a newb at preprocessor magic, so any advice would be useful. For whatever reason this translates out to 'module)' when I try to compile it with -E -P. The idea is that it will add to the modules list (assuming the modules list exists) the module to be registered, which should just be a type. Thanks,
Someone can correct me here, but I believe you can't use preprocessor directives (#define, #if, etc.) within a macro definition, and, well, who knows what'll happen if you try :/
- Jeff Right, and to address your desired use case a little more specifically, I don't think you can store state in the preprocessor in between macro invocations (if I'm wrong, please correct me, I would find such an ability very useful as well).
Regards, Nate
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Take care, Ty http://tds-solutions.net The aspen project: a barebones light-weight mud engine: http://code.google.com/p/aspenmud He that will not reason is a bigot; he that cannot reason is a fool; he that dares not reason is a slave.
participants (3)
-
Jeffrey Lee Hellrung, Jr.
-
Littlefield, Tyler
-
Nathan Ridge