ZBasic Language Reference
78
ZBasic Microcontrollers
3.12 Include Directive
You may use an include directive in a source file to cause another source file to be compiled as well. The
form of the include directive is:
#include "<filename>"
The <filename> element is the name of the file that you want to have compiled. If the filename is not
specified using an absolute path (i.e. beginning with the root directory and/or a drive letter), the path
prefix (if any) of the current module will be appended to the front of the filename. Note, however, that if
an --include-path option is specified on the command line or a #include_path directive precedes
the #include in the source code, a filename specified with a relative path will, instead, be sought among
the directories specified in the include path list. See Section 10.2 for more information on the --
include-path option. See the next section for information about the #include_path directive.
Note that the effect of the include directive is no different than if you had instructed the compiler directly to
compile the file. It is compiled as a separate module.
BasicX Compatibility Note
Include directives are not supported in BasicX compatibility mode.
3.13 Include_path Directive
You may specify a list of directories in which to searh for files to be included via #include in the cases
where the filename is not absolute. The include path is also used when importing definitions from
external C/C++ header files using the #import directive (see section 6.8). The include path directive has
the following form.
#include_path "<directory_list>"
Note that this directive may be used as many times as needed but the path list specified most recently
preceding a particular #include or #import directive will be the one in effect for that operation.
Whitespace preceding and following directory names in the path list is ignored and the entire semicolon-
separated list must be enclosed in double quotes. Further, either forward slash or backslash may be
used as directory separators within the pathnames. If a component of the directory list ends with a slash
(or backslash) followed by an at sign (@), that directory and all subordinate directories will be added to
the include path.
Two special "macros" may be used in the directory list. Firstly, the character sequence $(ZBASIC) will
be replaced by the full pathname to the subdirectory of the ZBasic installation directory containing the file
zbasic.h. Secondly, the character sequence $(INCPATH) will be replaced with the include path that
existed before the directive was processed. The latter macro allows directories to be added to the
existing path.
Examples
#include_path "C:\arduino-0022\hardware\arduino\cores\arduino"
#include_path "C:\My Projects/subdir; C:/mydir2;D:/subdir/dir3"
3.14 Using Conditional Directives in Project and Argument Files
|