是否应在生成文件中使用局部变量的较长同义词



make(我正在使用OpenBSD的实现,但我想这个问题也与GNU make有关),我们有以下所谓的局部变量

@    The name of the target
%    The name of the archive member (for library rules)
!    The name of the archive file (for library rules)
?    The list of prerequisites for this target that were deemed out of date
<    The name of the prerequisite from which this target is to be built (for inference rules)
*    The file prefix of the file, containing only the file portion, no suffix or preceding directory components

(大致来自 OpenBSD 上的 make(1)

这些局部变量具有同义词:用于 exampe,.IMPSRC 表示 <.TARGET 表示 @ 。FreeBSD 中的手册说这些较长的版本是首选。OpenBSD的手册页没有提到这样的事情,但说这些较长的名称是一个扩展。

使用较长的名称更好吗?哪个兼容性更好?都是POSIX吗?

这些变量在GNU make中称为自动变量,在POSIX标准中称为内部变量

这些的长名称纯粹是BSD制造发明,它们不存在于任何其他版本的make(如GNU make)中,并且在POSIX标准中也没有提到它们。

是否要使用它们取决于您,但它们是完全不可移植的。 当然,如果要实现兼容层,始终可以自己定义它们。

最新更新