这是我的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

其他回答

关键点是“HARD TAB”

检查是否使用TAB而不是空格 检查.vimrc中的set tabstop=X

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

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

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

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

如果你在这里搜索如何使你添加的选项卡和新行可以通过vim理解,你必须首先在vim中启用选项卡。

你可以在添加制表符之前使用:set noet即(从空格切换到制表符)。

使用这个命令,您的选项卡将看起来像其他选项卡(即^I)和***缺少分隔符。停止。make的错误将消失:)

在你做了更改之后,你可以用set et切换回来

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

Make定义了开始每个食谱所需的TAB。每条规则的所有操作都由制表符标识。如果您喜欢使用制表符以外的字符作为食谱的前缀,则可以将. recipeprefix变量设置为另一个字符。

为了检查,我使用命令cat -e -t -v makefile_name。

它显示了以^I结尾的制表符和以$结尾的行。这两者对于确保依赖关系正确结束至关重要,并且制表符标记规则的操作,以便make实用程序容易识别它们。

例子:

Kaizen ~/so_test $ cat -e -t -v  mk.t
all:ll$      ## here the $ is end of line ...                   
$
ll:ll.c   $
^Igcc  -c  -Wall -Werror -02 c.c ll.c  -o  ll  $@  $<$ 
## the ^I above means a tab was there before the action part, so this line is ok .
 $
clean :$
   \rm -fr ll$
## see here there is no ^I which means , tab is not present .... 
## in this case you need to open the file again and edit/ensure a tab 
## starts the action part