是否可以定义输出二进制整数的M4宏?例如:
define(`foo', $1)
foo(42)
应输出1个字节,值为42。
答案 0 :(得分:0)
define(`foo', `esyscmd(`python -c "import sys; sys.stdout.write(chr($1))"')') dnl
foo(`42')
扩展为:
*
但这有点像作弊。
答案 1 :(得分:0)
在GNU m4 there is a format
macro中,它以C函数printf
为模型。
% gm4 define(`chr', `format(`%c', `$1')')dnl 42 is chr(`42') 42 is *
这在FreeBSD附带的m4中不起作用。