2013-03-04 23 views
6

I (ben yazmadım o) bir programı derlemek çalışıyorum ve aşağıdaki hatayı alıyorum:"İfadesiz" #elif "ne anlama geliyor?

#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 

Hat 6 hat sadece geçerli: def.h şöyle

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 

Dosya#error "L defined elsewhere"'dan önce.

Derleyici geçerli:

$ 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. 

herhangi bir fikir nasıl düzeltilir?

cevap

20

#elif, #if gibi bir ifade beklediğinden dolayı. #else'u kullanmak istiyorsunuz.

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

(eşdeğer)

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

Bundan emin misiniz: Aksi takdirde ifade vermek zorunda? Ben bir kamu repo – user000001

+0

@ user000001 indirilen: Bu konuda oldukça eminim. Bununla birlikte, halk tarafından kullanılan derleyicinin boş bir ifadeyi '0' olarak yorumlaması mümkün olabilir; bu da söz konusu segmentin hiç bir derlemesini içermeyecektir. Ama sadece yazım hatası gibi görünüyor. – Zeta

+0

Denedim ve işe yarıyor gibi görünüyor. Thanx! – user000001