-
#undef
I'm having trouble with #undef... it doesn't seem to be changing anything... at the top of my header file I have this:
#define BOOST_ANY_TYPECHECK
I want, inside the template function change_type, to use #undef to undefine it, run the function, and then redefine it if it was defined.
This doesn't seem to be working... is it local to the function itself if you use it inside a function?
-
The preprocessor runs before the compiler, so preprocessor directives are run before your code is compiled. I'm not sure how much this helps, but I didn't take the time to fully understand your problem. It's late :p
-
I want to change a define... maybe I should try using a global variable... lemme try that real quick.
Nevermind, its useless... I still need to find why the templates aren't changing each time or it won't work.
-
"is it local to the function itself if you use it inside a function?"
My book says that #define(and therefore #undef) does not respect scope and cannot be bound within a namespace.
-
But it might still not help you. I don't know what BOOST_ANY_TYPECHECK does, but if it changes the behaviour of the boost headers then undefining or defining it for one of your functions makes no difference. It only makes a difference at the point where you include the boost headers. Like with the windows header and _WIN32_LEAN_AND_MEAN:
Code:
// _WIN32_LEAN_AND_MEAN tells windows.h not to include
// rarely used headers, thus fastening compilation.
#define _WIN32_LEAN_AND_MEAN
#include <windows.h>
// ...
int WinMain(...
// ...
// We want multimedia functions in this function, so let's undo
// the non-inclusion:
#undef _WIN32_LEAN_AND_MEAN
void DoMultimedia(int type)
{
// ...
}
#define _WIN32_LEAN_AND_MEAN
// But this DOESN'T WORK!
// It only makes a difference at the point where windows.h gets included.
-
I´m not sure but I think your answer is here
Pay attention to Polymorphic OOP reply.
-
Those are entirely different matters.