gpt4 book ai didi

makefile - 你能制作没有制表符的有效 Makefile 吗?

转载 作者:行者123 更新时间:2023-12-03 04:43:36 25 4
gpt4 key购买 nike

target: dependencies
command1
command2

在我的系统(Mac OS X)上,make似乎要求Makefiles在每个命令行行的内容之前有一个制表符,否则它会抛出一个语法错误。

这在创建或编辑 Makefile 时很烦人,因为我将编辑器设置为全时都是空格。

你能制作没有制表符的有效 Makefile 吗?

最佳答案

这是 make 的语法奇怪/要求,它与 Mac OS X 无关。不幸的是,如果您要使用 make<,您对此无能为力。/.

编辑:GNU Make 现在支持自定义配方前缀。请参阅this answer .

您不是第一个不喜欢 make 这方面的人。引用Unix Haters' Handbook :

The problem with Dennis’s Makefile is that when he added the comment line, he inadvertently inserted a space before the tab character at the beginning of line 2. The tab character is a very important part of the syntax of Makefiles. All command lines (the lines beginning with cc in our example) must start with tabs. After he made his change, line 2 didn’t, hence the error.

“So what?” you ask, “What’s wrong with that?”

There is nothing wrong with it, by itself. It’s just that when you consider how other programming tools work in Unix, using tabs as part of the syntax is like one of those pungee stick traps in The Green Berets: the poor kid from Kansas is walking point in front of John Wayne and doesn’t see the trip wire. After all, there are no trip wires to watch out for in Kansas corn fields. WHAM!

关于makefile - 你能制作没有制表符的有效 Makefile 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2131213/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com