2012-10-02 62 views
1

我不斷收到這個錯誤,當我嘗試編譯我的代碼:C的誤差:預計表達式之前A.A令牌

cc -Wall -Werror -g -c -o lwp.o lwp.c 
lwp.c: In function ânew_intel_stackâ: 
lwp.c:120: error: expected expression before â.â token 
lwp.c:122: error: expected expression before â.â token 
lwp.c:124: error: expected expression before â.â token 
lwp.c:126: error: expected expression before â.â token 
lwp.c:130: error: expected expression before â.â token 
lwp.c:132: error: expected expression before â.â token 
lwp.c:134: error: expected expression before â.â token 
lwp.c:136: error: expected expression before â.â token 
lwp.c:138: error: expected expression before â.â token 
lwp.c:140: error: expected expression before â.â token 
lwp.c:142: error: expected expression before â.â token 
make: *** [lwp.o] Error 1 

它指的是該功能是在這裏:

/* make ourselves a nice intuitive "push()" macro */ 
#define push(sp,val) (*(..sp)=(unsigned)(val)) 

unsigned long *new_intel_stack(unsigned long *sp,lwpfun func, void *arg) { 
    unsigned long *ebp; 
    push(sp,arg); /* argument */ 
    push(sp,lwp_exit); /* for lwp return purposes */ 
    push(sp,func); /* function's return address */ 
    push(sp,0x1abcdef1); /* bogus "saved" base pointer */ 
    ebp=sp; /* remember sp from this point for later */ 
    push(sp,0x6c6f7453); /* push initial eax, ebx, ecx, edx, esi and edi -- bogus */ 
    push(sp,0x66206e65); 
    push(sp,0x206d6f72); 
    push(sp,0x746e6957); 
    push(sp,0x32207265); 
    push(sp,0x21363030); 
    push(sp,ebp); /* push initial edp */ 
    return sp; 
} 

我不知道爲什麼我得到這個錯誤。有任何想法嗎?

+0

您使用哪種編譯器? – Macmade

回答

4

錯誤是由宏內部..序列引起的。

什麼是..應該在宏定義什麼意思?

(*(..sp)=(unsigned)(val)) 

沒有什麼在C語言中,將符合您的是..的使用。 C有.運算符,但不能像它在宏中使用的方式那樣使用。

+1

這應該是一個評論... – Macmade

+0

這就是答案! – cYrus

+0

{..}序列實際上應該是{ - }。謝謝! – user1715445

0

您是不是要找

#define push(sp,val) (*(--sp)=(unsigned)(val)) 

+0

是的,這就是我的意思。謝謝! – user1715445

相關問題