It is C++. I can use templates (although I would prefer to steer clear of it for the time being).
The problem is that I have written piece of code that dynamically loads shared libraries at run time (dlopen/dlclose/dlsym). Each module must have a unique ID and it needs to be checked for a correct value (!=0). I do this at load time as well, but it would be great if there was a way to do the checks at module compile time so people know of invalid ID's before the time of loading. For now, I have written a small preprocessor which is "checking" the module for correctness. Not the prettiest thing in the world, but it works. Thanks Manohar On Fri, Mar 26, 2010 at 5:29 PM, coderbean <[email protected]> wrote: > > On Mar 25, 2010, at 10:42 AM, Manohar Vanga wrote: > > Does anyone know if the following code can be made to work? Alternative >> would also be appreciated: >> >> #define INIT_MODULE(id) \ >> #if (id == 0)\ >> #error "Invalid ID"\ >> #else\ >> #define __MODULE_ID__\ >> int __module_id = id;\ >> #endif >> >> The __MODULE_ID__ is required later on in the preprocessing. Any >> suggestions? I would hate to have to sit and write my own preprocessor :-/ >> >> > Can you please tell what exactly you are trying to achieve here? Is this C > or C++? Can you use templates instead of preprocessor? > > Thanks >> Manohar >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >

