Thanks Grant, here's some context on what I'm working on and what I tried. I'm using m4 as the macro processor of an Intel 8080 cross-assembler I'm developing in Python (nothing fancy, I'm a hobbyist). I'd like to write macros for generating unique Assembly labels that would be good approximations of local labels.
An approach is to generate the labels from the unique values of a global counter, hence my question. I'm thinking of something like: define(`nextlabel', `L'nextcount) nextlabel: mvi a, 3 My initial attempt was like this: define(`COUNTER', `0') define(`newlabel', ``$1'incr(COUNTER)') But this is ineffective as no global COUNTER can be referenced. Then I tried this: define(`newlabel', pushdef(`COUNTER', `incr(COUNTER)')`$1'COUNTER) which generates an infinite loop. Another approach I tried is to fetch a unique integer from outside of m4 via esyscmd: define(`newlabel', `$1'esyscmd(`date +"%s"|tr -d "\n"')) This aborts m4 with an internal error and %s isn't granular enough anyway. A variation on esyscmd I experimented with is: define(`newlabel',`$1'esyscmd(`echo $RANDOM|tr -d "\n"')) Which returns an empty string. Paolo