Class A uses a library written in C. This library provides some data types and constants which are used in A. Unfortunately, the library also defines macros in its header file, which collide with my C++ code in main.cpp or in other classes using A.
How can I prevent macros of c_library.h being executed when A.h is included somewhere? I would also be open for architectural changes, but I would prefer not to touch the C library.
Of course, there's the #undef directive. But this would mean a lot of manual work for every macro or for every collision. (Ok, there are not too many - but hey, this must be possible more elegant?)
Code:
//main.cpp
#include "A.h"
...
A a(...)
...
std::max(x, y); // oops, problem since max is defined as macro in c_library.h
...
//A.h
#include "c_library.h"
class A{
public:
A(...);
static void callbackForCLibrary(datatypeOfCLibrary d){...}
private:
private datatypeOfCLibrary1;
private datatypeOfCLibrary2;
}