Rolf Magnus wrote:
> #elif is not the same as a combination of #else and #ifdef, but rather
> #else and #if. And #if requires an expression, which is missing if the
> macro isn't defined.
Rolf makes a good point, but a better solution is to use the improved
preprocessor syntax introduced in ANSI C in 1989! Despite its 20 year
history, this K&R syntax is still prevalent; I have no idea why. This is
what you need (already suggested by Stefan Ernst rather more succinctly
and without the rant):
1 | #define XYZ
|
2 | #define WITHB
|
3 |
|
4 | #if defined XYZ
|
5 | #if defined WITHA
|
6 | if (count < 1000) {
|
7 | save[count] = (short)IP;
|
8 | count++;
|
9 | }
|
10 | #elif defined WITHB
|
11 | if (count < 1000) {
|
12 | save[count] = temp;
|
13 | count++;
|
14 | }
|
15 | #endif
|
16 | #endif
|
That way you never need to assign a value to the macros; their mere
existence is enough.
I have no idea what "Guest" was talking about; in what language is
#elsif valid I wonder!? Certainly non-standard, and not documented in
the GNU C preprocessor:
http://gcc.gnu.org/onlinedocs/cpp/Index-of-Directives.html#Index-of-Directives