I have some C++ code that includes a method called CreateDirectory().
Previously the code only used STL and Boost, but I recently had to include
push
macro, undef
it and pop
the macro again:
#pragma push_macro("CreateDirectory")
#undef CreateDirectory
void MyClass::CreateDirectory()
{
// ...
}
#pragma pop_macro("CreateDirectory")
As a developer working on a cross platform codebase, this is a problem. The only way to deal with it is to
OR, if that is an unpleasant proposition, (and it is for me)
If your utlility functions need to include project header files with conflicting symbols then the following pattern is a necessity:
#include <windows.h>
#ifdef CreateDirectory
#undef CreateDirectory
#endif
// etc
#include "some_class_with_CreateDirectory_method.h"
// ...
You will need to then explicitly call the non macro version of any windows api functions you have #undef'd - CreateDirectoryA or W etc.