开发者

M4 binary output

Is it possible to define a M4 macro that outputs a binary integer? F开发者_JAVA技巧or example:

define(`foo', $1)
foo(42)

which should output 1 byte with a value of 42.


define(`foo', `esyscmd(`python -c "import sys; sys.stdout.write(chr($1))"')') dnl
foo(`42')

Expands to:

*

That's a bit of a cheat, though.


In GNU m4 there is a format macro which is modeled after the C function printf.

% gm4
define(`chr', `format(`%c', `$1')')dnl
42 is chr(`42')
42 is *

This won't work in m4 that ships with FreeBSD.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜