m4 processor

m4 is a macro processor, in the sense that it copies its input to the output, expanding macros as it goes. Macros are either builtin or user-defined, and can take any number of arguments. Besides just doing macro expansion, m4 has builtin functions for including named files, running shell commands, doing integer arithmetic, manipulating text in various ways, performing recursion, etc.… m4 can be used either as a front-end to a compiler, or as a macro processor in its own right. - GNU M4

Doc

preprocessor features

m4 --synclines --prefix-builtins -I directory -D name[=value] -U name inputFiles.m4 > target

m4 offers these facilities:

  • a free-form syntax, rather than line based syntax
  • a high degree of macro expansion (arguments get expanded during scan and again during interpretation)
  • text replacement
  • parameter substitution
  • file inclusion
  • string manipulation
  • conditional evaluation
  • arithmetic expressions
  • system interface
  • programmer diagnostics
  • programming language independent
  • human language independent
  • provides programming language capabilities
Written on February 27, 2019, Last update on August 30, 2023
c++ macro string