2015-11-07 48 views
0

我想通過編譯這個源代碼來獲取這個惱人的錯誤,並且我不知道爲什麼會發生這些錯誤。我已經搜索了,但我沒有發現任何有用的東西。

的資源文件

#include <ddk/ntddk.h> 
#include <internal/ntoskrnl.h> 
#include <internal/ke.h> 
#include <internal/i386/segment.h> 


#define _STR(x) #x 
#define STR(x) _STR(x) 


#define IRQ_HANDLER_FIRST(x,y) \ 
     void irq_handler_##y (void); \ 
     __asm__("\n\t.global _irq_handler_"##x"\n\t_irq_handler_"##x":\n\t" \ 
     "pusha\n\t"      \ 
     "pushl %ds\n\t"     \ 
     "pushl %es\n\t"     \ 
     "pushl %fs\n\t"     \ 
     "movl $0xceafbeef,%eax\n\t"  \ 
     "pushl %eax\n\t"    \ 
     "movw $"STR(KERNEL_DS)",%ax\n\t"  \ 
     "movw %ax,%ds\n\t"    \ 
     "movw %ax,%es\n\t"    \ 
     "inb $0x21,%al\n\t"    \ 
     "orb $1<<"##x",%al\n\t"  \ 
     "outb %al,$0x21\n\t"    \ 
     "pushl %esp\n\t"    \ 
     "pushl $"##x"\n\t"    \ 
     "call _KiInterruptDispatch\n\t"\ 
     "popl %eax\n\t"    \ 
     "popl %eax\n\t"    \ 
     "popl %eax\n\t"    \ 
     "popl %fs\n\t"     \ 
     "popl %es\n\t"     \ 
     "popl %ds\n\t"     \ 
     "popa\n\t"      \ 
     "iret\n\t") 

#define IRQ_HANDLER_SECOND(x,y) \ 
     void irq_handler_##y (void); \ 
     __asm__("\n\t.global _irq_handler_"##x"\n\t_irq_handler_"##x":\n\t" \ 
     "pusha\n\t"      \ 
     "pushl %ds\n\t"     \ 
     "pushl %es\n\t"     \ 
     "pushl %fs\n\t"     \ 
     "movl $0xceafbeef,%eax\n\t"  \ 
     "pushl %eax\n\t"    \ 
     "movw $"STR(KERNEL_DS)",%ax\n\t"  \ 
     "movw %ax,%ds\n\t"    \ 
     "movw %ax,%es\n\t"    \ 
     "inb $0xa1,%al\n\t"    \ 
     "orb $1<<("##x"-8),%al\n\t"  \ 
     "outb  %al,$0xa1\n\t"    \ 
     "pushl %esp\n\t"    \ 
     "pushl $"##x"\n\t"    \ 
     "call _KiInterruptDispatch\n\t"\ 
     "popl %eax\n\t"    \ 
     "popl %eax\n\t"    \ 
     "popl %eax\n\t"    \ 
     "popl %fs\n\t"     \ 
     "popl %es\n\t"     \ 
     "popl %ds\n\t"     \ 
     "popa\n\t"      \ 
     "iret\n\t") 


IRQ_HANDLER_FIRST ("0",0); 
IRQ_HANDLER_FIRST ("1",1); 
IRQ_HANDLER_FIRST ("2",2); 
IRQ_HANDLER_FIRST ("3",3); 
IRQ_HANDLER_FIRST ("4",4); 
IRQ_HANDLER_FIRST ("5",5); 
IRQ_HANDLER_FIRST ("6",6); 
IRQ_HANDLER_FIRST ("7",7); 
IRQ_HANDLER_SECOND ("8",8); 
IRQ_HANDLER_SECOND ("9",9); 
IRQ_HANDLER_SECOND ("10",10); 
IRQ_HANDLER_SECOND ("11",11); 
IRQ_HANDLER_SECOND ("12",12); 
IRQ_HANDLER_SECOND ("13",13); 
IRQ_HANDLER_SECOND ("14",14); 
IRQ_HANDLER_SECOND ("15",15); 

然後我得到類似的東西

ke/i386/irqhand.c:25:9: error: pasting ""orb $1<<"" and ""5"" does not give a 
valid preprocessing token 
     "orb $1<<"##x",%al\n\t"  \ 
     ^
ke/i386/irqhand.c:72:1: note: in expansion of macro 'IRQ_HANDLER_FIRST' 
IRQ_HANDLER_FIRST ("5",5); 
^ 
ke/i386/irqhand.c:28:9: error: pasting ""pushl $"" and ""5"" does not give a val 
id preprocessing token 
     "pushl $"##x"\n\t"    \ 
     ^
ke/i386/irqhand.c:72:1: note: in expansion of macro 'IRQ_HANDLER_FIRST' 
IRQ_HANDLER_FIRST ("5",5); 
^ 
ke/i386/irqhand.c:14:16: error: pasting ""\n\t.global _irq_handler_"" and ""6"" 
does not give a valid preprocessing token 
     __asm__("\n\t.global _irq_handler_"##x"\n\t_irq_handler_"##x":\n\t" \ 
       ^
ke/i386/irqhand.c:73:1: note: in expansion of macro 'IRQ_HANDLER_FIRST' 
IRQ_HANDLER_FIRST ("6",6); 
^ 
ke/i386/irqhand.c:14:46: error: pasting ""\n\t_irq_handler_"" and ""6"" does not 
give a valid preprocessing token 
     __asm__("\n\t.global _irq_handler_"##x"\n\t_irq_handler_"##x":\n\t" \ 
              ^
ke/i386/irqhand.c:73:1: note: in expansion of macro 'IRQ_HANDLER_FIRST' 
IRQ_HANDLER_FIRST ("6",6); 
^ 
ke/i386/irqhand.c:25:9: error: pasting ""orb $1<<"" and ""6"" does not give a 
valid preprocessing token 
     "orb $1<<"##x",%al\n\t"  \ 
     ^
ke/i386/irqhand.c:73:1: note: in expansion of macro 'IRQ_HANDLER_FIRST' 
IRQ_HANDLER_FIRST ("6",6); 
^ 
ke/i386/irqhand.c:28:9: error: pasting ""pushl $"" and ""6"" does not give a val 
id preprocessing token 
     "pushl $"##x"\n\t"    \ 
     ^
ke/i386/irqhand.c:73:1: note: in expansion of macro 'IRQ_HANDLER_FIRST' 
IRQ_HANDLER_FIRST ("6",6); 
^ 
ke/i386/irqhand.c:14:16: error: pasting ""\n\t.global _irq_handler_"" and ""7"" 
does not give a valid preprocessing token 
     __asm__("\n\t.global _irq_handler_"##x"\n\t_irq_handler_"##x":\n\t" \ 
       ^
ke/i386/irqhand.c:74:1: note: in expansion of macro 'IRQ_HANDLER_FIRST' 
IRQ_HANDLER_FIRST ("7",7); 
^ 
ke/i386/irqhand.c:14:46: error: pasting ""\n\t_irq_handler_"" and ""7"" does not 
give a valid preprocessing token 
     __asm__("\n\t.global _irq_handler_"##x"\n\t_irq_handler_"##x":\n\t" \ 
              ^
ke/i386/irqhand.c:74:1: note: in expansion of macro 'IRQ_HANDLER_FIRST' 
IRQ_HANDLER_FIRST ("7",7); 
^ 
ke/i386/irqhand.c:25:9: error: pasting ""orb $1<<"" and ""7"" does not give a 
valid preprocessing token 
     "orb $1<<"##x",%al\n\t"  \ 
     ^
ke/i386/irqhand.c:74:1: note: in expansion of macro 'IRQ_HANDLER_FIRST' 
IRQ_HANDLER_FIRST ("7",7); 
^ 
ke/i386/irqhand.c:28:9: error: pasting ""pushl $"" and ""7"" does not give a val 
id preprocessing token 
     "pushl $"##x"\n\t"    \ 
     ^
ke/i386/irqhand.c:74:1: note: in expansion of macro 'IRQ_HANDLER_FIRST' 
IRQ_HANDLER_FIRST ("7",7); 
^ 
ke/i386/irqhand.c:41:16: error: pasting ""\n\t.global _irq_handler_"" and ""8"" 
does not give a valid preprocessing token 
     __asm__("\n\t.global _irq_handler_"##x"\n\t_irq_handler_"##x":\n\t" \ 
       ^
ke/i386/irqhand.c:75:1: note: in expansion of macro 'IRQ_HANDLER_SECOND' 
IRQ_HANDLER_SECOND ("8",8); 
^ 
ke/i386/irqhand.c:41:46: error: pasting ""\n\t_irq_handler_"" and ""8"" does not 
give a valid preprocessing token 
     __asm__("\n\t.global _irq_handler_"##x"\n\t_irq_handler_"##x":\n\t" \ 
              ^
ke/i386/irqhand.c:75:1: note: in expansion of macro 'IRQ_HANDLER_SECOND' 
IRQ_HANDLER_SECOND ("8",8); 
^ 
ke/i386/irqhand.c:52:9: error: pasting ""orb $1<<("" and ""8"" does not give a 
valid preprocessing token 
     "orb $1<<("##x"-8),%al\n\t"  \ 
     ^
ke/i386/irqhand.c:75:1: note: in expansion of macro 'IRQ_HANDLER_SECOND' 
IRQ_HANDLER_SECOND ("8",8); 
^ 
ke/i386/irqhand.c:55:9: error: pasting ""pushl $"" and ""8"" does not give a val 
id preprocessing token 
     "pushl $"##x"\n\t"    \ 
     ^
ke/i386/irqhand.c:75:1: note: in expansion of macro 'IRQ_HANDLER_SECOND' 
IRQ_HANDLER_SECOND ("8",8); 
^ 
ke/i386/irqhand.c:41:16: error: pasting ""\n\t.global _irq_handler_"" and ""9"" 
does not give a valid preprocessing token 
     __asm__("\n\t.global _irq_handler_"##x"\n\t_irq_handler_"##x":\n\t" \ 
       ^
ke/i386/irqhand.c:76:1: note: in expansion of macro 'IRQ_HANDLER_SECOND' 
IRQ_HANDLER_SECOND ("9",9); 
^ 

如何得到這個問題的拼車?

回答

0

擺脫宏定義中的##。在這種情況下它們是不必要的和非法的。由於錯誤表明##運算符的結果必須是單個有效的預處理令牌,並且"pushl $""6"是兩個令牌。

如果沒有##,預處理器將不會嘗試將兩個字符串粘貼在一起形成單個令牌。它們將作爲單獨的字符串標記保留,這些標記將在稍後的翻譯階段合併在一起。

相關問題