Reputation: 1744
I want to expose the private members when debuging, like this:
class A {
public:
void f1();
#ifndef NDEBUG
public:
#else
private:
#endif
void f2();
};
I want to use macros like:
#define PUBLIC public:
#define PRIVATE \
\#ifndef NDEBUG \
public: \
\#else \
private: \
\#endif
but, well, I know this won't work...
Is there anything that you guys recommend?? Thx in advance.
Edit 01:
My purpose is not to debug
my code, but to test the private member functions.
Upvotes: 3
Views: 91
Reputation:
You can't, the preprocessor doesn't have reflection. But you can do it the normal (ugh, arguably...) way:
#ifndef NDEBUG
#define PRIVATE public:
#else
#define PRIVATE private:
#end
Upvotes: 4
Reputation: 17339
Simply define PRIVATE
differently depending on NDEBUG
:
#ifndef NDEBUG
#define PRIVATE public
#else
#define PRIVATE private
#endif
Upvotes: 6