我定义了这个宏:
(defmacro with-current-directory (directory &rest body)
"Set the working directory temporarily set to DIRECTORY and run BODY.
DIRECTORY is expanded"
`(let ((default-directory
,(file-name-as-directory
(expand-file-name (eval directory)))))
,@body))
#define EVAL1(...) __VA_ARGS__
#define RECURSE() I am recursive, look: _RECURSE()()
#define _RECURSE() RECURSE
I expected:
EVAL1(RECURSE())
=> EVAL1(I am recursive, look: _RECURSE()())
=> EVAL1(I am recursive, look: RECURSE())
=> I am recursive, look: RECURSE()
=> I am recursive, look:I
我有一个像这样的宏
macro multishift(L...)
ex = :(0)
for d in L
ex = :($ex | 1 << Int32($d))
end
return ex
end
因此,@multishift(1,2)将扩展到0 | 1 << Int32(1) | 1 << Int32(2)。现在,我添加了一个类似这样的函数,并称之为:
f(L...) = @multishift(L...)
println(f(1,2))
这不管用。我会得到一个没有定义L的错误。我可以看到这里发生了什么
#define B 100+B
main()
{
int i= B;
}
我知道这是错误的,但出于好奇,当我编译它时,我得到了一个奇怪的错误:
"B未在这一范围内宣布“。
为什么会这样呢?如果此错误是因为编译器在宏替换后删除了它,那么下面的代码如何正常工作,当B在提供给A之前必须已经删除了?
#define B 100
#define A 100+B
main()
{
int i= B;
int j =A;
}
可能重复:
当我这么做时:
RANGE_COUNT=28
for i in {0..$RANGE_COUNT} ; do echo $i; done
我明白了
{0..28}
当我这么做时:
for i in {0..5} ; do echo $i; done
我明白了:
0
1
2
3
4
5
这是怎么回事,我如何使它做我明确的意图和显然没有正确的陈述?
在试图解决Project中的问题时,我编写了以下函数和宏:
(defun digits (n &key (base 10)) ;; Returns a list with the digits of 'n'
(if (< n base) (list n) ;; in a given base.
(multiple-value-bind (div rem)
(floor n base)
(concatenate 'list (digits div :base base) (list rem))
我在构建一些文件集的时候遇到了下面的错误。有人能给我一些关于为什么我会得到这个错误的提示吗?我是不是错过了某个包的安装? 错误日志片段: make[1]: MMD: Command not found
CC drivers/usb/usbhid.libc.o
make[1]: MMD: Command not found
CC drivers/usb/usbmsc.libc.o
make[1]: MMD: Command not found
CC drivers/hid.libc.o
make[1]: MMD: Comm
我想要生成一个等价目标的列表:
TARGETLIST = a b c d e f
define RULE
$(subst X,$(1),file_X.txt) $(subst X,$(1),otherfile_X.txt) &: # some dependency
# some commands
endef
$(foreach _t, $(TARGETLIST), $(eval $(call RULE, $(_t))))
这不符合我的要求:例如,如果我想构建file_b.txt,就找不到菜谱。我该怎么解决这个问题?