C - 转到位于外部文件中的标签

Mat*_*lst 4 c label extern

假设我有 2 个 C 源文件A.c,B.c.

A.c包含一个标签,我只想从模块中获取该标签B.c。

A.c仅包含 1 个函数:

int f() {
   // some commands
   aLabel:
   // some more commands
   return 1;
}
Run Code Online (Sandbox Code Playgroud)

B.c也只包含 1 个函数:

extern aLabel;

int g() {
  // do some stuff
  goto aLabel;
}
Run Code Online (Sandbox Code Playgroud)

显然,这两个文件链接在一起形成最终的 .exe 文件。

如何跳转到外部标签?

提前致谢。

oua*_*uah 5

goto始终是函数的本地函数,因此无法使用 . 在函数之间跳转goto。要进行非本地跳转,请看一下 a setjmp/ longjmpC 函数。