Skip to content
Search

M4

lastmod 2018-08-17created 2014-12-274 edits

m4 is a macro processing language. It was created by Dennis Ritchie and Brian Kernighan. It is usually used in programming to reuse existing text templates, but it is also used for many other purposes.

Back when programmers wrote a lot of assembly language, they devised a way to abbreviate frequently repeated parts of assembly code. Later this was extended to producing different values by changing only the arguments of a macro, which eventually led to macro processors. It was first created in 1977 and was used to implement Rational Fortran. Today the m4 reimplemented by GNU is widely used.

Like most general-purpose languages, m4 is Turing complete.

Hello world

A simple m4 program that prints the string "Hello world" for Python is shown below.

define(string, Hello world)dnl
print "string"

Favorite site

References


  1. Solanara.net_-_M4,_GNU_M4.pdf ↩

  2. Korea.gnu.org-manual-release-m4.zip ↩