回复 9楼 longwu9t
你看看我《麻雀解剖》的帖子,那里就提到extern怎么用,在什么地方用。extern只是外部符号声明,针对模块间数据的。变量声明的范围比extern还要广。
授人以渔,不授人以鱼。
(gdb) disassemble display_line Dump of assembler code for function display_line: 0x000000000040155e <+0>: push rbp 0x000000000040155f <+1>: mov rbp,rsp 0x0000000000401562 <+4>: sub rsp,0x30 0x0000000000401566 <+8>: mov DWORD PTR [rbp-0x4],0x0 0x000000000040156d <+15>: jmp 0x40157d <display_line+31> 0x000000000040156f <+17>: mov ecx,0x2a 0x0000000000401574 <+22>: call 0x402b18 <putchar> 0x0000000000401579 <+27>: add DWORD PTR [rbp-0x4],0x1 0x000000000040157d <+31>: cmp DWORD PTR [rbp-0x4],0x1d 0x0000000000401581 <+35>: jle 0x40156f <display_line+17> 0x0000000000401583 <+37>: add rsp,0x30 0x0000000000401587 <+41>: pop rbp 0x0000000000401588 <+42>: ret 0x0000000000401589 <+43>: nop 0x000000000040158a <+44>: nop 0x000000000040158b <+45>: nop 0x000000000040158c <+46>: nop 0x000000000040158d <+47>: nop 0x000000000040158e <+48>: nop 0x000000000040158f <+49>: nop End of assembler dump.