Encyclopedia > M4

  Article Content


M4 is a macro processing language.

A list of M4 resources may be found at http://www.m4site.com

A macro processor is a text-replacement tool. Its chief use is to re-use text templates, typically in programming applications, but also in text editing, text processing applications.

Macro processors were prevalent when assembly language programming was the common tool of programmers. In these early days of programming, the programmers noted that much of their program was repeated text. Simple means to re-use this text were invented. Programmers soon discovered it easy to not only reuse entire blocks of text, but, on occasion, substitute different values for similar parameters. This defined the usage range of macro processors.

M4 offers these facilities:

  • text replacement
  • parameter substitution
  • file inclusion
  • string manipulation
  • conditional evaluation
  • arithmetic expressions
  • system interface
  • programmer diagnostics

Different from most earlier macro processors, it is not targeted at any particular computer or human language.

An example:

 define(`Name', `A very very long name')


After being processed with m4:

 m4 inputfile >outputfile

The outputfile will look like

 printf("A very very long name\n") 

There is a GNU version of m4.

Link: (http://www.gnu.org)

  • The M4 is a major British motorway which runs from Chiswick, west of London, into Wales.
  • The M4 is also a motorway in Sydney, Australia, running from the western suburb of Emu Plains to the inner western suburb of Strathfield.
  • The M4 is also a carbine version of the M16 rifle.

All Wikipedia text is available under the terms of the GNU Free Documentation License

  Search Encyclopedia

Search over one million articles, find something about almost anything!
  Featured Article
Johann Karl Friedrich Rosenkranz

... at the university of Königsberg[?], where he remained till his death. In his last years he was quite blind. Throughout his long professorial career, and in all his ...

This page was created in 31.2 ms