Copyright (C) 2000-2012 |
GNU Info (nasm.info)Section 4.64.6. Including Other Files ========================== Using, once again, a very similar syntax to the C preprocessor, NASM's preprocessor lets you include other source files into your code. This is done by the use of the `%include' directive: %include "macros.mac" will include the contents of the file `macros.mac' into the source file containing the `%include' directive. Include files are searched for in the current directory (the directory you're in when you run NASM, as opposed to the location of the NASM executable or the location of the source file), plus any directories specified on the NASM command line using the `-i' option. The standard C idiom for preventing a file being included more than once is just as applicable in NASM: if the file `macros.mac' has the form %ifndef MACROS_MAC %define MACROS_MAC ; now define some macros %endif then including the file more than once will not cause errors, because the second time the file is included nothing will happen because the macro `MACROS_MAC' will already be defined. You can force a file to be included even if there is no `%include' directive that explicitly includes it, by using the `-p' option on the NASM command line (see *Note Section 2.1.11::). automatically generated by info2www version 1.2.2.9 |