$IMPORT common.msg

The imported file is parsed with the same state: settings it changes stay changed after the $IMPORT, and its messages are part of the module. Its $MODULE, $NAMESPACE or $EXPORT would change the module too — keep those in the main file.

Search order

For a relative name:

  1. the folder of the importing file,
  2. the working folder,
  3. the mstring -I folders, in order.

An absolute name is used as it is. A missing file is an error:

main.msg:2:9: error: import file 'common.msg' does not exist

Rules

  • The $IMPORT line closes the message above it; an imported file starts with no open message.
  • A file that (directly or indirectly) imports itself is an error: error: recursive $IMPORT of 'a.msg'.
  • An error in an imported file is reported at its own position, followed by error in imported file '…' at the $IMPORT line.
  • With mstring_generate(), list imported files under DEPENDS so that editing them regenerates the module.