What does "#elif with no expression" mean?

c, gcc

Solution

Because `#elif` expects an expression, just like `#if`. You want to use `#else`. Otherwise you have to give the expression:

#ifndef L
  #define L 152064 /* (352 * 288 * 1.5) */
#elif defined(L)
  #error "L defined elsewhere"
#endif

(equivalent)

#ifndef L
  #define L 152064 /* (352 * 288 * 1.5) */
#else
  #error "L defined elsewhere"
#endif

Problem

I am trying to compile a program (that I did not write) and I get the following error: ``` C read.c ... In file included from read.c:6:0: def.h:6:6: error: #elif with no expression make: *** [read.o] Error 1 ``` File `def.h` looks like this: ``` #ifndef TRACE_DEF #define TRACE_DEF #ifndef L #define L 152064 /* (352 * 288 * 1.5) */ #elif #error "L defined elsewhere" #endif #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif #ifndef MAX #define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif ``` Line 6 is the line just before `#error "L defined elsewhere"`. Compiler is: ``` $ gcc --version gcc-4.6.real (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ``` Any ideas how to fix it?

Original source