1

コードをコンパイルしようとすると、このエラーが発生し続けます。

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;
}

このエラーが発生する理由がよくわかりません。何か案は?

4

2 に答える 2

4

エラーは..、マクロ内のシーケンスが原因です。

..マクロ定義で何を意味するはずですか?

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

その使用法に一致するものは C 言語にはありません..。C には.演算子がありますが、マクロ内で使用される方法では使用できません。

于 2012-10-02T20:59:04.627 に答える
0

もしかして

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

??

于 2012-10-02T21:00:41.393 に答える