Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "#elif with no expression" mean?

Tags:

c

gcc

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?

like image 387
user000001 Avatar asked Mar 04 '13 14:03

user000001


People also ask

What the Fox say Meaning?

Speaking of the meaning of the song, Vegard characterizes it as coming from "a genuine wonder of what the fox says, because we didn't know". Although interpreted by some commentators as a reference to the furry fandom, the brothers have stated they did not know about its existence when producing "The Fox".

What is this song Google?

Ask Google Assistant to name a song On your phone, touch and hold the Home button or say "Hey Google." Ask "What's this song?" Play a song or hum, whistle, or sing the melody of a song. Hum, whistle, or sing: Google Assistant will identify potential matches for the song.


1 Answers

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
like image 90
Zeta Avatar answered Nov 15 '22 06:11

Zeta