Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 359 Vote(s) - 3.47 Average
  • 1
  • 2
  • 3
  • 4
  • 5
#ifdef inside #define

#1
I am trying to write something like this:

#define COV_ON(x) \
#ifdef COVERAGE_TOOL \
_Pragma (COVERAGE #x)
#endif

Is there any way to define `COV_ON` like this? I know what I have done above is wrong as I can't have `#ifdef` inside #define. (`#` is not an allowed character in `#define`).
So is there any solution?
Reply

#2
Simply turn it around:

#ifdef COVERAGE_TOOL
#define COV_ON(x) _Pragma (COVERAGE #x)
#else
#define COV_ON(x) /* foo */
#endif
Reply

#3
#ifdef COVERAGE_TOOL
#define COV_ON(x) _Pragma (COVERAGE #x)
#else
#define COV_ON(x)
#endif

Reply

#4
You cannot. But you can swap `#ifdef` and `#define`:

#ifdef COVERAGE_TOOL
# define COV_ON(x) _Pragma (COVERAGE #x)
#else
# define COV_ON(x)
#endif
Reply

#5
Not possible. Do it the other way around:

#ifdef COVERAGE_TOOL
#define COV_ON(x) _Pragma (COVERAGE #x)
#else
#define COV_ON(x)
#endif


Reply

#6
As you mentioned it is not possible to have an #ifdef in a #define. What you should do instead is reverse the order:

#ifdef COVERAGE_TOOL \
#define COV_ON(x) \
etc.
#endif
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through