Navigation bar
  Start Previous page
 108 of 172 
Next page End  

ZBasic Language Reference
101
ZX Microcontroller Family
#pragma StackUse( <procedure-name>, <stack-depth> )
The recommended method used to generate an estimate of the stack use is to examine the assembly
listing file generated by the compiler in response to the –-list option (which also requires the –-keep-
files option) and manually compute the maximum stack depth.  Use of this method requires an
understanding of AVR assembly code and is therefore recommended for advanced users only.
4.7 Creating and Using Object Libraries
It is often useful to create a library of code elements from which the essential elements are drawn when
building an application.  Such libraries can then be easily reused in several applications or distributed to
other ZBasic users for use in building their applications. The ZBasic compiler supports the creation of
object libraries only for native mode devices.
To instruct the ZBasic compiler to build a library instead of building a downloadable file as it normally
does, add the option –-create-library to your project file.  If no filename is specified with that option,
the library name will be same as the project name but with the extension .a.  The compiler will create an
additional file containing ZBasic declarations for all of the public elements in the library; this file with have
the same name as the library but with the extension .inc.  It is important to note that none of the ZBasic
files compiled into the library should have a public subroutine named Main().
To use the library in a ZBasic application, it is only necessary to add the name of the declarations file to
that application’s project file or, alternately, to include the declarations file in one of your modules (e.g. the
Main() module) using the #include directive.  Generally, the declarations file and the library file should
be kept in the same directory.  The declarations file contains a directive to tell the compiler the name of
the corresponding library file – that’s why it doesn’t need to be explicitly mentioned.
If you create library files to distribute to others, you only need to supply the declarations file and the library
file.  The source code for the library needn’t be distributed if you’d like to keep it proprietary.
Previous page Top Next page