DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(m4.info.gz) Location

Info Catalog (m4.info.gz) Errprint (m4.info.gz) Miscellaneous (m4.info.gz) M4exit
 
 13.2 Printing current location
 ==============================
 
 To make it possible to specify the location of an error, three utility
 builtins exist:
 
  -- Builtin: __file__
  -- Builtin: __line__
  -- Builtin: __program__
      Expand to the quoted name of the current input file, the current
      input line number in that file, and the quoted name of the current
      invocation of `m4'.
 
      errprint(__program__:__file__:__line__: `input error
      ')
      error-->m4:stdin:1: input error
      =>
 
    Line numbers start at 1 for each file.  If the file was found due to
 the `-I' option or `M4PATH' environment variable, that is reflected in
 the file name.  The syncline option (`-s',  Invoking m4), and the
 `f' and `l' flags of `debugmode' ( Debug Levels), also use this
 notion of current file and line.  Redefining the three location macros
 has no effect on syncline, debug, or warning message output.  Assume
 this example is run in the `checks' directory of the GNU M4 package,
 using `--include=../examples' in the command line to find the file
 `incl.m4' mentioned earlier:
 
      define(`foo', ``$0' called at __file__:__line__')
      =>
      foo
      =>foo called at stdin:2
      include(`incl.m4')
      =>Include file start
      =>foo called at ../examples/incl.m4:2
      =>Include file end
      =>
 
    Currently, all text wrapped with `m4wrap' ( M4wrap) behaves
 as though it came from line 0 of the file "".  It is hoped that a
 future release of `m4' can overcome this limitation and remember which
 file invoked the call to `m4wrap'.
 
    The `__program__' macro behaves like `$0' in shell terminology.  If
 you invoke `m4' through an absolute path or a link with a different
 spelling, rather than by relying on a `PATH' search for plain `m4', it
 will affect how `__program__' expands.  The intent is that you can use
 it to produce error messages with the same formatting that `m4'
 produces internally.  It can also be used within `syscmd' (
 Syscmd) to pick the same version of `m4' that is currently running,
 rather than whatever version of `m4' happens to be first in `PATH'.
 
Info Catalog (m4.info.gz) Errprint (m4.info.gz) Miscellaneous (m4.info.gz) M4exit
automatically generated byinfo2html