如何在编译时为每个源文件添加单独的宏 #3392
Answered
by
waruqi
shenxing1206
asked this question in
Q&A
如何在编译时为每个源文件添加单独的宏
#3392
-
场景是在日志输出时需要打印当前文件名,不带目录。 在makefile中可以直接以如下方式写这个宏
` 请问在xmake中要如何实现此功能呢? |
Beta Was this translation helpful? Give feedback.
Answered by
waruqi
Feb 19, 2023
Replies: 1 comment
-
直接代码里走 target("")
for _, file in ipairs(os.files("src/*.c")) do
add_files(file, {defines = "FILENAME=" .. path.filename(file)})
end |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
shenxing1206
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
直接代码里走
__FILE__
,解析提取下名字不就完事了,干嘛这么麻烦,都回显 logs 了,也不差这点性能。