M4

The term M4 has several meanings: This article is about the M4 macro processing language.

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

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

An example:

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

printf("Name\\n");

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.

External links


">
" size=20>

 
 

Browse articles alphabetically:
#0">0 | #1">1 | #2">2 | #3">3 | #4">4 | #5">5 | #6">6 | #7">7 | #8">8 | #9">9 | #_">_ | #A">A | #B">B | #C">C | #D">D | #E">E | #F">F | #G">G | #H">H | #I">I | #J">J | #K">K | #L">L | #M">M | #N">N | #O">O | #P">P | #Q">Q | #R">R | #S">S | #T">T | #U">U | #V">V | #W">W | #X">X | #Y">Y | #Z">Z