【发布时间】:2021-01-14 05:16:37
【问题描述】:
我创建了几个 test*.c 文件
$ ls
Makefile test2.c test3.c test4.c test5.c test6.c test7.c test8.c test9.c
除了文件名和函数名之外,所有的 test*.c 都有相同的代码
$ cat test2.c
#include <stdio.h>
int test_2_()
{
return 0;
}
$ cat test3.c
#include <stdio.h>
int test_3_()
{
return 0;
}
$ cat test4.c
#include <stdio.h>
int test_4_()
{
return 0;
}
Makefile 很简单,只是 echo $(src):
$ cat Makefile
src = $(wildcard *.c)
seq:
@echo $(src)
现在,我的问题是通配符的顺序是什么
$ make seq
test2.c test4.c test6.c test3.c test8.c test9.c test5.c test7.c
如果按字母顺序排列,应该是“test2.c test3.c test4.c ...”,但实际上是“test2.c test4.c test6.c test3.c test8.c test9.c”测试5.c 测试7.c" 而且不遵循文件更新时间顺序
$ for i in `ls test*`;do echo $i;touch $i;sleep 1;done
test2.c
test3.c
test4.c
test5.c
test6.c
test7.c
test8.c
test9.c
$ make seq
test2.c test4.c test6.c test3.c test8.c test9.c test5.c test7.c
【问题讨论】:
-
如果您希望它们排序,请使用
sort,如$(sort $(wildcard *.c))