0

I'm trying to get this to work, but so far haven't been able to think of anything.

So; what I want is a keyword that I can use in my code that would always return a different answer. This will be used for obsfucation for my program (please don't ask why).

For example:

#define __JUNK0  ... manual junk code here ...
#define __JUNK1  ... manual junk code here ...
#define __JUNK2  ... manual junk code here ...
#define __JUNK3  ... manual junk code here ...

#define ADD_JUNK

void main()
{
    ADD_JUNK; // adds __JUNK0
    ADD_JUNK; // now adds __JUNK1
    ADD_JUNK; // and now adds __JUNK2
    ADD_JUNK; // and finally __JUNK3
}

I tried to mess around with __COUNTER__, but then realized you can't make a "define function"...

I was also thinking about using constexpr, but how would I use that on a switch in compile time that basically adds an __forceinline function?

Is this even possible? Any ideas? <3

Kordnak
  • 165
  • 10
  • The preprocessor is The Devil. – Eljay Aug 19 '19 at 21:07
  • 1
    This question seems slightly different than the one it's marked as duplicating. That said, take a look at Magnus' answer in particular (third one down), but use `__COUNTER__` instead of `__LINE__` and that should do the trick for you. If the result produced by the macro matches another defined value (e.g., `__JUNK0`, etc) it will do the proper translation. – Charles Ofria Aug 19 '19 at 21:27

0 Answers0