1

consider the following

#if TABLE_SIZE>200
#undef TABLE_SIZE
#define TABLE_SIZE 200

The macro TABLE_SIZE is being compared

is it possible that its compared with a non numeric value like,

#if MACRO==ABCDEF123

I tried it but compiler complains of ABCDEF123 not being defined and assumes it as 0.

Osaid
  • 557
  • 1
  • 8
  • 23
  • 2
    Reopened as this is also tagged C++ which could attract constructive template-based solutions. – Bathsheba Apr 13 '16 at 09:25
  • @Bathsheba, actually I upvoted your comment for reopening this Q. But I realized that macros & templates don't get along in this context. I am not sure about the history of this Q. Was the linked Q only marked as duplicate earlier? Nevertheless, I don't see that anything beyond the answers given in that post is possible. Also it seems that, the code in this Q as it is (with `#endif`) actually compiles fine. Mostly OP meant whatever is asked in the linked Q. – iammilind Apr 13 '16 at 09:35

1 Answers1

0

For true portability, the expression in #IF expression can only contain integer and character constants. The C and C++ preprocessors can also evaluate +, -, *, /, <<, >>, !=, == and the two logical operators && and || which obey the short-circuiting rules of standard C and C++.

So no, you can't compare a string directly.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483