带有反斜杠的字符串宏\

Fen*_*ang 2 macros julia

是否可以将单个尾随\字符传递给字符串宏?

macro test_str(s)
    s
end

test"\\"  # results in \\, that is two backslashes
test"\"   # does not parse ... the " is treated as escaped
Run Code Online (Sandbox Code Playgroud)

Lyn*_*ite 5

这是一个解决方法,但您可以直接调用宏 - 作为宏而不是字符串宏

@test_str("\\") 工作良好.