Page 153 of 229 Start Back Next End ZBasic Language Reference 143 ZBasic Microcontrollers Chapter 10 - Compiler Guide The ZBasic compiler is a modern design that employs some advanced optimization techniques to reduce code and data size while at the same time reducing execution time. The compiler operates in several stages including syntactic analysis, semantic analysis and code generation. During each of the first two phases error messages or warnings may be generated. Even though these are logically separate passes, the resulting error output lists errors by line number to facilitate easier resolution. Error messages may be generated during the code generation phases but this should generally not occur. Note that the compiler may generate “spurious” error messages due to earlier detected error conditions. Consequently, fixing the cause of some earlier error messages may result in later messages being eliminated on the next compilation. By default, error messages are routed to the stderr device meaning that they will appear on the console unless redirected to a file. Alternately, the compiler can be directed to output the error messages to a specifically named file. The error messages are formatted in a manner to allow an Integrated Development Environment or advanced text editor to automatically position the cursor at the next error message. The default error messages format is: <filename>:<line-number>:<error-message> where <filename> is the full name of the file containing the offending line, <line-number> is the line that contained the error (or, in the case of continued lines, the line number of the first continued segment) and <error-message> is a description of the detected condition. The <error-message> text includes an indication of whether the detected condition is an error condition or just a warning. There is a class of error messages that reflect the occurrence of a set of conditions that weren’t expected and shouldn’t normally occur. If the compiler generates such “internal error” messages we would like to know the circumstances that produced them so that we can rectify the problem. There is probably not much that you can do to work around the problem in such cases but it may help to turn off all optimization (see Section 10.2 for details). The ZBasic compiler is a “console program” meaning that it has no graphical user interface. The compiler is invoked via a command line that specifies the compiler options and the files to compile. One of the compiler options allows you to specify an “arguments file” that contains a list of options and/or files. Another option allows you to specify a “project file”. This is similar to specifying an arguments file except that the use of a project file affects some filename defaults as described in subsequent sections. 10.1 Compiler Invocation The general form of the compiler invocation is: zbasic [<options>] [<files>] where <options> represents one or more compiler options and <files> represents one or more files to be compiled. Both of these command line elements are optional; if neither is specified, a summary of the command line options is displayed. On the Windows platform, a file specification may contain “wild card” characters. For example, the file specification “*.bas” refers to all of the files having the .bas extension in the current directory. Note that command line options and filenames may appear on the command line in any order and may appear multiple times. The options and files are processed left to right and when a filename is encountered the file is processed (syntactically analyzed) using the options in effect at that point in time. To understand how the intermixing of options and filenames affects the entire process, it is necessary to be aware that certain options are applied to files immediately as the files are encountered while other options are not applied until all files have been processed. If you utilize one of the options in the latter group multiple times, only the last instance will have an effect. In the tables below, the options that are immediately applied to files as they are processed are denoted with an asterisk preceding the description.