这是我的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.
我该怎么解决呢?
这是我的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.
我该怎么解决呢?
当前回答
在VS Code中,在编辑你的Makefile时,只需点击“Space: 4”,并将其更改为tab。
其他回答
TLDR;
Makefile语法可能很古怪 如果你想让一行代码被解释为make代码,那么它只能用空格缩进。 如果您希望将一行代码解释为bash代码,则必须只使用制表符缩进
sometask:
ifeq ($FOO,bar) // this is make code. only spaces
echo "foobar" // this is bash code. only tabs
endif // again, this is make code. only spaces
从技术上讲,它是指示解释器的首缩进。
这是因为制表符被空格取代。 若要禁用此功能,请转到
中- >编辑- >首选项- >编辑器
并删除检查
"用空格替换制表符"
如果你在eclipse中编辑你的Makefile:
Windows-> Preferences->General->Editor->Text Editors->Show Whitespace Characters -> Apply
或使用下面显示的快捷方式。
Tab用灰色“>>”表示,Space用灰色“.”表示,如下图所示。
如果有人遇到这个问题
*** missing separator. Stop.
在构建过程中,他们应该仔细检查通往源代码的文件系统路径,它不应该包含像“#”这样的特殊字符。
例如,路径
/home/user/#my_sources/
可能无效
使用.editorconfig自动修复选项卡:
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
[Makefile]
indent_style = tab