小编Kak*_*aka的帖子

包含循环 - 链接器或编译器错误?

我想知道包含文件的无限循环是否会导致编译器问题或链接器问题.我试过这个:

/* file : try.c */
#include "try1.c"
int main(void) {}

/* file : try1.c */
#include "try.c"
int a(void) { return 0; }
Run Code Online (Sandbox Code Playgroud)

编译命令是:

gcc -Wall try.c -o try
Run Code Online (Sandbox Code Playgroud)

这显然会导致很长的输出(像这样开始):

try.c:5:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
In file included from try.c:1:0,
                 from try1.c:1,
                 from try.c:1:
try1.c:4:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
In file included from try1.c:1:0,
                 from try.c:1:
try.c:5:1: error: expected '=', ',', ';', 'asm' or '__attribute__' …
Run Code Online (Sandbox Code Playgroud)

c compiler-construction linker loops

0
推荐指数
1
解决办法
373
查看次数

标签 统计

c ×1

compiler-construction ×1

linker ×1

loops ×1