1

I had the following structure:

#if COND
  ...
#endif
#elif COND2
  ...
#else
  ...
#endif

I have to replace elif with two statements: else and if:

#if COND
  ...
#endif
#else
  #if COND2
     ...
  #endif
#else     // error: #else after #else
  ...
#endif

What's wrong?

p.s. No I see what's wrong but how to write it without errors?

4
  • 2
    You indeed have an #else after an #else. Commented Mar 9, 2012 at 11:16
  • Which error message did you get? Commented Mar 9, 2012 at 11:18
  • Why do you have to replace it in the first place? What’s the problem with the first version (well, except for the wrong #endif)? Commented Mar 9, 2012 at 11:22
  • @KonradRudolph stackoverflow.com/questions/9631762/missing-binary-operator-c Commented Mar 9, 2012 at 11:23

1 Answer 1

2

You can't have two #else statements in the same #if.

The correct version would be:

#if COND
  ...
#else
  #if COND2
     ...
  #else
     ...
  #endif
#endif
Sign up to request clarification or add additional context in comments.

2 Comments

Okay, I see that. But how to replace in my case?
@Ockonal actually, this version is the correct one. You also had an #endif before the first #else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.