这是我的makefile:

all:ll

ll:ll.c   
  gcc  -c  -Wall -Werror -02 c.c ll.c  -o  ll  $@  $<

clean :
  \rm -fr ll

当我尝试make clean或make make时,我得到这个错误:

:makefile:4: *** missing separator.  Stop.

我该怎么解决呢?


当前回答

使用.editorconfig自动修复选项卡:

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4

[Makefile]
indent_style = tab

其他回答

如果你的编辑器/IDE支持它(很可能是支持的!),帮你自己一个忙,让它成为你的.editorconfig的永久成员。

[Makefile]
indent_style = tab

默认情况下,您应该始终在制表符后写入命令,而不是空格。可以将其更改为带有. recipeprefix变量的另一个字符。

这适用于gcc行(行#4)。您需要在gcc之前插入tab。

也用rm -fr ll替换\rm -fr ll。在此命令之前也要插入制表符。

如果你在eclipse中编辑你的Makefile:

Windows-> Preferences->General->Editor->Text Editors->Show Whitespace Characters -> Apply

或使用下面显示的快捷方式。

Tab用灰色“>>”表示,Space用灰色“.”表示,如下图所示。

当你在VSCode中创建Makefile时,你应该设置Tab Size: 4。

如果您正在使用mcedit进行makefile编辑。你必须看到下面的标记。