Is it possible to write define with spaces such as:
#define replace to replacement here
I want to replace "replace to" with "replacement here".
EDIT:
I want to test private members:
I did write
#define private public
but it didn't work for private slots in Qt
so my intend was to use something like
#define private slots: public slots:
anyway I have found another way to test slots and by the way I'm aware of that this is an ugly hack.
no, you can't
#define identifier something
what you define must be an identifier which cannot contain space. Nor can it contain hyphen, begin with a number, etc. you can define only an identifier
what you wrote will work
#define replace to replacement here
but not as you expect. This line defined replace
to be substituted with to replacement here
You could do...
#define replace replacement
#define to here
Watch out for unintended side effects of the defines. You would probably want to #undef
them after they've done their job.
If you are doing unit test, you can compile your file with the following flag
-Dprivate=public
Then in your unit test, you will be able to call every private method of your class.
EDIT:
I've recently remarked that using the -fno-access-control flag on gcc compiler allows you to access private method or member. More info on that topic can be found here: Unit testing with -fno-access-control
No, that's not possible. Why not just do this instead:
#define replace_to replacement here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With