I am very new to m4 but cannot find this simple thing:
Is it possible to expand a macro in the middle of a word? (I would use it for a counter that would be used in a C symbol name in low-level code)
I mean like:
define(`foo',`bar')
Happy fooday!
The expected output would be:
Happy barday!
It is even ok to do it like this:
Happy expand(foo)day!
Sorry if this is a very easy question but my googling attempts failed on 'm4 expand macro in word, m4 expand substring', etc...
Thanks
EDIT 1:
StackOverflow recommended this: Expansion of macro not working in M4 ...which is indeed what I was looking for.
EDIT 2:
Ok, it is not that easy:
define(`foo',`bar')
Happy asdfoo()day!
This fails, which might be normal. However, in my C symbol names I have to substitute these macros in the middle of the words. What would be the way to go for that?
I believe you are looking for:
define(`foo',`bar')
Happy `'foo`'day!
That is, use the m4 quotes to indicate the word boundary. Or, more accurately, use an empty string on either side of the word you wish to have expanded, and indicate the boundaries of that empty string with quotes.