Harbour Reference Guide - Document

Document

License

GNU License

Sub category
License
Gnu License File Part 1
Description
GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or vmodify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
<b>TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION</b>
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
See also
GNU License..
Index
Document

GNU License..

Sub category
License
Gnu License File Part 2
Description
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
<b>NO WARRANTY</b>
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
<b>END OF TERMS AND CONDITIONS</b>
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found:
<One line to give the program's name and an idea of what it does.> Copyright (C) yyyy <name of author>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but <b>WITHOUT ANY WARRANTY</b>; without even the implied warranty of <b>MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE</b>. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
signature of Ty Coon, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.
FSF & GNU inquiries & questions to gnu@gnu.org. Copyright notice above.
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA Updated: 3 Jan 2000 rms
See also
License,GNU License
Index
Document

Harbour License

Sub category
License
Harbour License
Description
<b>THE HARBOUR PROJECT COMPILER LICENSE</b>
====================================
Note: This license applies to most of the files in the src/compiler
directory.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
their web site at http://www.gnu.org/).
<b>THE HARBOUR PROJECT LIBRARY LICENSE</b>
===================================
Note: This license applies to most of the files in the include directory,
source directory, and subdirectories.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this software; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
As a special exception, the Harbour Project gives permission for
additional uses of the text contained in its release of Harbour.
The exception is that, if you link the Harbour libraries with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of
linking the Harbour library code into it.
This exception does not however invalidate any other reasons why
the executable file might be covered by the GNU General Public License.
This exception applies only to the code released by the Harbour Project under the name Harbour. If you copy code from other Harbour Project or Free Software Foundation releases into a copy of Harbour, as the General Public License permits, the exception does not apply to the code that you add in this way. To avoid misleading anyone as to the status of such modified files, you must delete
this exception notice from them.
If you write modifications of your own for Harbour, it is your choice whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice.
<b>THE OLD HARBOUR PROJECT LIBRARY LICENSE</b>
=======================================
Note: This license only applies to the following files: <pre>
contrib\libmisc\dates2.c (Only the DateTime() function by Jon Berg) samples\pe\* source\rtl\philes.c source\rtl\binnum.c source\lang\msgsr852.c source\lang\msgpl852.c source\lang\msgpliso.c source\lang\msgplmaz.c source\lang\msgeu.c source\lang\msgcsiso.c source\lang\msgcswin.c source\lang\msgcskam.c source\lang\msgsriso.c source\lang\msgde.c source\lang\msghr852.c source\lang\msgcs852.c source\lang\msghriso.c source\lang\msgis850.c
</pre> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version, with one exception:
The exception is that if you link the Harbour Runtime Library (HRL) and/or the Harbour Virtual Machine (HVM) with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the HRL
and/or HVM code into it.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
their web site at http://www.gnu.org/).
<b>THE HARBOUR PROJECT CONTRIB LICENSE</b>
===================================
There is no one single license that applies to the Harbour Project contrib files. Some files use the Harbour Project Compiler license. Some files use the Harbour Project Library license. Some files use the old Harbour Project Library license (and in one case, just one function in a file that otherwise uses the Harbour Project Library license uses the old license - this is the DateTime() function in the file contrib\libmisc\dates2.c). Some files may even use other types of free software or open source software licenses. Some files have been donated to the public domain. If you use any of the contrib
files, you need to investigate the license that applies to each file.
See also
Overview
Index
Document

Compiler

Command line utility

Sub category
Compiler
Compiler Options
Description
This spec goes for CLIPPERCMD, HARBOURCMD, Harbour compiler and #pragma directives in the source code.
The command line always overrides the envvar.
Note that some switches are not accepted in envvar, some others in #pragmas.
First the parser should start to step through all the tokens in the string separated by whitespace. (or just walk through all argv[])
1.) If the token begins with "-", it should be treated as a new style switch.
One or more switch characters can follow this. The "-" sign inside the token will turn off the switch.
If the switch has an argument all the following characters are treated as part of the argument.
The "/" sign has no special meaning here.

Switch Result option
-wn ( W N )
-w-n ( !W N )
-wi/harbour/include/ ( W I=/harbour/include/ )
-wi/harbour/include/n ( W I=/harbour/include/n )
-wes0n ( W ES=0 N )
-wen ( W [invalid switch: e] N )
-wesn ( W ES=default(0) N )
-wses ( W S ES=default(0) )
-wess ( W ES=default(0) S )
- ( [invalid switch] )
-w-n-p ( !W !N P )
-w-n-p- ( !W !N !P )
-w- -w -w- ( finally: !W )

2.) If the token begins with "/", it should be treated as a compatibility style switch.
The parser scans the token for the next "/" sign or EOS and treats the resulting string as one switch.
This means that a switch with an argument containing "/" sign has some limitations. This may be solved by allowing the usage of quote characters. This is mostly a problem on systems which use "/" as path separator.
The "-" sign has no special meaning here, it can't be used to disable a switch.

Switch Result option
/w/n ( W N )
/wo/n ( [invalid switch: wo] N )
/ihello/world/ ( I=hello [invalid switch: world] [invalid switch: /] )
/i"hello/world/"/w ( I=hello/world/ W )
/ihello\world\ ( I=hello\world\ )

3.) If the token begins with anything else it should be skipped.
The Harbour switches are always case insensitive.
In the Harbour commandline the two style can be used together: harbour -wnes2 /gc0/q0 -iC:\hello
Exceptions:
- Handlig of the /CREDIT undocumented switch on Harbour command line is unusual, check the current code for this.
- The CLIPPER, HARBOUR and Harbour application command line parsing is a different beast, see cmdarg.c for a NOTE.
Notes:
- All occurences where a path is accepted, Harbour should handle the
quote char to specify path containing space, negative sign, slash, or any other chars with special meaning.
/i"C:/hello/"
-i"C:/hello-n"
/i"C:/Program Files/"
-i"C:/Program Files/"
<fixed>
Just some examples for the various accepted forms: //F20 == /F20 == F20 == F:20 == F20X //TMPPATH:C:\hello F20//TMPPATH:/temp///F:30000000 NOIDLE F0NOIDLEX10 SQUAWKNOIDLE
</fixed>
"//" should always be used on the command line.
See also
Compiler Options
Index
Document

Compiler Options

Sub category
Compiler
Compiler Options
Description
<b>Invoking the Harbour compiler: </b>
==============================
harbour <file[.prg]> [options]
or
harbour [options] <file[.prg]>
or
harbour [options] <file[.prg]> [options]
The command line options have to be separated by at least one space. The option can start with either '/' character or '-' character.
<b>The Harbour command line options: </b>
=================================
/a automatic memvar declaration
=================
This causes all variables declared by PARAMETER, PRIVATE or PUBLIC statements to be automatically declared as MEMVAR variables.
/b debug info
=================
The compiler generates all information required for debugging
/d<id>[=<val>] #define <id>
=================
/es[<level>] set exit severity
=================
/es or /es0 - all warnings are ignored and exit code returned by
the compiler (accessed by DOS ERRORLEVEL command) is equal to 0 if there are no errors in compiled source file.
/es1 - any warnings generate a non-zero exit code, but
output is still created.
/es2 - all warnings are treated as errors and no output
file is created. The exit code is set to a non-zero value.
/g<type> output type generated is <type>
=================
/gc[<type>] output type: C source (.c) (default)
<type>: 0=compact 1=normal 2=verbose (default)
3=generate real C code instead of PCODE
array called by a C wrapper.
/go output type: Platform dependant object module
/gh output type: Harbour Portable Object (.hrb)
/i<path> add #include file search path
=================
/k<mode> enable <mode> compatibility mode
=================
/kc clear all flags (strict CA-Cl*pper compatibility)
/kh Harbour extensions (default)
/ki HB_INLINE support enabled (default)
/kr use runtime settings for the macro compiler
/ks enable support for strings as array of bytes (default)
/kx other Xbase++ dialects extensions (default)
/kJ disable optimalization of jump and noop pcodes
/k? invoke help information
/l suppress line number information
=================
The compiler does not generate the source code line numbers in the output file. The PROCLINE() function will return 0 for modules compiled using this option.
/m compile current module only
=================
/n no implicit starting procedure
=================
The compiler does not create a procedure with the same name as the compiled file. This means that any declarations placed before the first PROCEDURE or FUNCTION statement have file- wide scope and can be accessed/used in all functions/procedures defined in the compiled source file. All executable statements placed at the beginning of the file and before the first PROCEDURE/FUNCTION statement are ignored.
/o<path> output file drive and/or path
=================
/p generate pre-processed output (.ppo) file
=================
The compiler only creates the file that contains the result of pre-processing the source file.
/q quiet
=================
The compiler does not print any messages during compiling (except the copyright info).
/q0 be really quiet and don't display even the copyright info
/r[<lib>] request linker to search <lib> (or none)
=================
Currently not supported in Harbour.
/r=<max> sets maximum number of preprocessor iterations
=================
This set the maximum number of preprocessor iterations during processing the source code. If this switch is not used then the preprocessor stops after 1024 iterations. This value is used to stop processing of infinite loops, for example: #command ( => (,7
/s syntax check only
=================
The compiler checks the syntax only. No output file is generated.
/t<path> path for temp file creation
=================
Currently not used in Harbour (the Harbour compiler does not create any temporary files).
/u[<file>] use command definition set in <file> (or none)
=================
/v variables are assumed M->
=================
All undeclared or unaliased variables are assumed MEMVAR variables (private or public variables). If this switch is not used then the scope of such variables is checked at runtime.
/w[<level>] set warning level number (0..4, default 1)
=================
/w0 - no warnings
/w or /w1 - CA-Cl*pper compatible warnings
/w2 - some useful warnings missed in CA-Cl*pper
/w3 - warnings generated for Harbour language extensions
and also enables strong type checking but only warns against declared types, or types which may be calculated at compile time
/w4 - Enables warning about suspicious operations, which
means if you mix undeclared types, or types which can not be calculated at compile time,together with declared types, a warning will be generated.
/x[<prefix>] set symbol init function name prefix (for .c only)
=================
Sets the prefix added to the generated symbol init function name (in C output currently). This function is generated automatically for every PRG module compiled. This additional prefix can be used to suppress problems with duplicated symbols during linking an application with some third party libraries.
/y trace lex & yacc activity
=================
The Harbour compiler uses the FLEX and YACC utilities to parse the source code and to generate the required output file. This option traces the activity of these utilities.
/z suppress logical shortcutting (.and. & .or.)
=================
Compilation in batch mode.
==========================
@<file> compile list of modules in <file>
=================
Not supported yet.
<b>Known incompatibilities between Harbour and CA-Cl*pper compilers </b>
=============================================================
NOTE:
If you want a 100% compatible runtime libraries then you have to define HARBOUR_STRICT_CLIPPER_COMPATIBILITY. This option should be defined in the file include/hbsetup.h (in fact this option is placed in a comment by default - you need to remove the /* */ characters only). This change has to be done before invoking the make utility.
<b>Handling of undeclared variables </b>
================================
When a value is assigned to an undeclared variable and the '-v' command line option is not used, then the CA-Cl*pper compiler assumes that the variable is a PRIVATE or a PUBLIC variable and generates POPM (pop memvar) opcode.
When the value of an undeclared variable is accessed and the '-v' command line option is not used, the CA-Cl*pper compiler generates PUSHV (push variable) opcode that determines the type of variable at runtime. If a field with the requested name exists in the current workarea then its value is used. If there is no field then a PRIVATE or a PUBLIC variable is used (if exists).
The Harbour compiler generates an opcode to determine the type of variable at runtime (POPVARIABLE or PUSHVARIABLE) in both cases (assignment and access).
The difference can be checked by the following code:
<fixed>
PROCEDURE MAIN() PRIVATE myname
DBCREATE( "TEST", { { "MYNAME", "C", 10, 0} } ) USE test NEW SELECT test APPEND BLANK
FIELD->myname := "FIELD" MEMVAR->myname := "MEMVAR"
myname := myname + " assigned"
// In CA-Cl*pper: "FIELD", In Harbour: "FIELD assigned" ? FIELD->myname
// In CA-Cl*pper: "MEMVAR assigned", In Harbour: "MEMVAR" ? MEMVAR->myname
USE
RETURN
</fixed>
<b>Passing an undeclared variable by the reference </b>
===============================================
The CA-Cl*pper compiler uses the special opcode PUSHP to pass a reference to an undeclared variable ( '@' operator ). The type of passed variable is checked at runtime (field or memvar). However, field variables cannot be passed by reference. This means that CA-Cl*pper checks the memvar variable only and doesn't look for a field. This is the reason why the Harbour compiler uses the usual PUSHMEMVARREF opcode in such cases. Notice that the runtime behavior is the same in CA-Cl*pper and in Harbour - only the generated opcodes are different.
Handling of object messages
===========================
The HARBOUR_STRICT_CLIPPER_COMPATIBILITY setting determines
the way chained send messages are handled.
For example, the following code:
a:b( COUNT() ):c += 1
will be handled as:
a:b( COUNT() ):c := a:b( COUNT() ):c + 1
in strict CA-Cl*pper compatibility mode and
temp := a:b( COUNT() ), temp:c += 1
in non-strict mode.
In practice, CA-Cl*pper will call the COUNT() function two times: the first time before addition and the second one after addition. In Harbour, COUNT() will be called only once, before addition.
The Harbour (non-strict) method is:
1) faster 2) it guarantees that the same instance variable of the same object will be changed
(See also: src/compiler/expropt.c)
<b>Initialization of static variables </b>
==================================
There is a difference in the initialization of static variables that are initialized with a codeblock that refers to a local variable. For example:
<fixed> PROCEDURE TEST() LOCAL MyLocalVar STATIC MyStaticVar := {|| MyLocalVar }
MyLocalVar :=0 ? EVAL( MyStaticVar )
RETURN </fixed>
The above code compiles fine in CA-Cl*pper, but it generates a runtime error Error/BASE 1132 Bound error: array access Called form (b)STATICS$(0)
In Harbour this code generates a compile time error: Error E0009 Illegal variable (b) initializer: 'MyLocalVar'
Both CA-Cl*pper and Harbour are handling all local variables used in a codeblock in a special way: they are detached from the local stack of function/procedure where they are declared. This allows access to these variables after the exit from a function/procedure. However, all static variables are initialized in a separate procedure ('STATICS$' in CA-Cl*pper and '(_INITSTATICS)' in Harbour) before the main procedure and before all INIT procedures. The local variables don't exist on the eval stack when static variables are initialized, so they cannot be detached.
Index
Document

Macro compiler

Sub category
Compiler
Macro compiler
Description
<b>Invoking the macro compiler: </b>
==============================
&variable
or
&( expression )
or
&variable.text
Index
Document

Strong Typing

Sub category
Compiler
Compile-Time type checking
Description
Strong Type Checking could also be described as "Compile-Time Type Checking".
CA-Cl*pper generates a Run-Time Error ("Type Mismatch") at an attempt to perform some operations with the wrong type of Variable.
Examples:
LOCAL Var1 := "A"
? Var1 * 3 // Error here.
@ Var1, 7 SAY 'Hello' // Error here.
? SubStr( "Hello", Var1 ) // Error here.
The above 3 lines would all result in Run-Time Error, because Var1 is of type CHARACTER but the above lines used it as if it was of type NUMERIC.
Using Strong Type Checking, or Compile-Time Type Checking, the above problem would have been discovered and reported in COMPILE-TIME, rather than waiting for the inevitable problem to be discovered when we finally execute the program.
Strong Typed Languages allow the programmer to "tell" the compiler (declare) what is the type of a each Variable, so that the Compiler in return can warn the programmer, when ever such Declared (Strong Typed) Variable, is used in a context which is incompatible with its declared type.
For instance, if we "told" the compiler that Var1 above is of type CHARACTER (LOCAL Var1 AS CHARACTER) the Harbour Compiler could, in return, warn us if we attempted to perform the calculation:
Var1 * 3
because the Compiler knows we can't perform a multiplication of a Character. (we might allow it in some context, but this is beyond the scope of this discussion). Similarly we would have been warned when attempting to use Var1 as a Row Number ( @ Var1 ), or as the 2nd operand of the SubStr() function SubStr( "Hello", Var1) ), because the Compiler knows that these operations require a NUMERIC rather than CHARACTER type.
The above may save us lots of time, by pointing a problem, we can not escape, since such code will never perform correctly once executed. So rather than wait to the testing cycle, for such problems to be discovered, (and some times even later, after we may have distributed our applications) instead we may know of such problems as soon as we type HARBOUR ProgName -w3
Harbour also offers a hybrid mode, where it can report such type mismatch problems, even without requiring the programmer to declare the type of variables. This feature, is referred to as Adaptive Type Checking. The programmer is not required to make any changes in his code to take advantage of this feature. All of the above 3 errors would have been reported just as effectively as if the programmer Strong Typed (declared) Var1. Harbour would have been able to report such problems at compile time because the assignment Var1 := "A" implied that Var1 is of type CHARACTER,until it will be assigned another value. Therefore Harbour will "remember" that Var1 "adapted" type CHARACTER, and thus the subsequent multiplication Var1 * 3, will be reported as an error, as soon as you attempt to compile such code.
The nice aspect of this hybrid mode, is that unlike Strong Typed Variables,you don't have to declare the type, so no code changes are need, the Type instead is assumed by implication (type of the assigned value). The other benefit, is that it is completely OK to assign a new value of different type, any time, to such undeclared (variant) variable. As soon as we assign a new type, the Compiler will than protect us from using the Variable in an incompatible context, since the variable "adapted" this type as soon as we assigned a value which implies a type.
While Adapted Type Checking may be fairly effective in reporting many common mistakes, to take full benefits of such Compile-Time checking, it is recommended to do declare the Type of Variables, when ever possible.
The Harbour Strong Type features, also allows the declaration of the expected parameters (including optionals) of User Defined Functions, as well as their return Type. Similarly, you may declare the Type of any Class Variables, Methods, and Methods Parameters.
Index
Document

Harbour Extensions

Harbour Extensions
Description
<b>Language extensions:</b> --------------------
* Class generation and management.
CA-Cl*pper only allowed creation of objects from a few standard classes.
In Harbour, you can create your own classes--complete with Methods, Instance Variables, Class Variables and Inheritance. Entire applications can be designed and coded in Object Oriented style.
* @<FunctionName>()
Returns the pointer (address) to a function.
The returned value is not useful to application-level programming, but is used at a low level to implement object oriented coding. (Internally, a class method is a static function and there is no symbol for it, so it is accessed via its address).
* Class HBGetList
Object oriented support for GetLists management.
* ProcName() support for class Method names.
Class Methods can be retrieved from the call stack.
* Memory() has new return values.
See hbmemory.ch
* Transform() --> new function in format string
@0 Make a zero padded string out of the number.
* SToD() --> dDate
New function that converts a yyyymmdd string to a Date value.
* Optional Compile Time STRONG TYPE declaration (and compile time TYPE
MISMATCH warnings)
Example: LOCAL/STATIC Var AS ...
* The Harbour debugger provides new interesting classes:
- Class TDbWindow could be the foundation for a generic multiplatform
- Class TForm
- Class TDbMenu implement both pulldown and popup menus.
<b>RTL enhanced functionality:</b> ---------------------------
- Directory( <cMask>, <cFlags>, <lEightDotThree> )
The 3rd parameter is a Harbour (optional) parameter and indicates that on those platforms that support long filenames, that you wish to receive what would be considered the dos equivalant 8.3 name. Could affect Adir() and Dir if they were modified to take advantage of it - currently, they will return long names if the os supports it.
- HB_DiskSpace( <nDrive>, <nType> )
The second parameter is a Harbour (optional) parameter and indicates the type of diskinfo being requested. See en/diskspac.txt for info.
Index
Document

OVERVIEW

HARBOUR Read me
Description
<b>The Harbour project</b>
<b>******************************************************************* *****</b> <b>* This file contains information on obtaining, installing, and using *</b> <b>* Harbour. Please read it *completely* before asking for help. *</b> <b>******************************************************************* *****</b>
Harbour is a free implementation of an xBase language compiler. It is designed to be source code compatible with the CA-Cl*pper(r) compiler. That means that if you've got some code that would compile using CA-Cl*pper(r) then it should compile under Harbour. The Harbour-Project web page is:
<b>http://harbour-project.org/</b>
Status and other information is always available from the web site. There is a Harbour mailing list. Harbour is still at a very early stage of development, so the mailing list is very much a Developers only list, although every body is welcome to join in the discussions.
We would like you to join the Harbour development team. If you are interested you may suscribe to our mailing list and start contributing to this free public project.
Please feel free to report all questions, ideas, suggestions, fixes, code, etc. you may need and want. With the help of all of you, the Harbour compiler and runtime libraries will become a reality very soon.
<b>What this distribution contains</b> ===============================
This distribution is a Source code only distribution. It does not contain any executable files. Executable versions of Harbour are available from the web site. Executable versions of Harbour DO NOT create runable programs. Harbour at the moment produces C output code, which must be compiled with the Harbour Virtual Machine and the support libraries in order to create a functioning program. Please test running Harbour against your CA-Cl*pper source code and report any problems that might occur.
Very important: The preprocessor functionality is now working.
<b>Installation</b> ------------
1. Unzip with Harbour zip file using pkunzip or equivalent.
E.G. pkunzip -d build72.zip
This will create Harbour/ directory and all the relevant sub directories.
2. Compile Harbour using your C compiler. Make files for different
platforms are included in the <WHERE ARE THEY?> directory.
<b>--- COPYRIGHT ---</b>
What copyright information do we have
<b>--- LICENCE ---</b>
Information about the License for usage of Harbour is available in the file licence.txt (when we have a license)
<b>--- DISCLAIMER ---</b>
Participants of The Harbour Project assume no responsibility for errors or omissions in these materials.
<b>THESE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.</b>
Participants of The Harbour Project further do not warrant the accuracy or completeness of the code, information, text, output or any other items contained within these materials. Participants of The Harbour Project shall not be liable for any special, direct, indirect, incidental, or consequential damages, including without limitation, lost revenues or lost profits, which may result from the use or mis-use of these materials.
The information in The Harbour Project is subject to change without notice and does not represent any future commitment by the participants of The Harbour Project.
The Harbour Project
See also
License
Index
Document

The Garbage Collector

Readme for Harbour Garbage Collect Feature
Description
The garbage collector uses the following logic: - first collect all memory allocations that can cause garbage; - next scan all variables if these memory blocks are still referenced.
Notice that only arrays, objects and codeblocks are collected because these are the only datatypes that can cause self-references (a[1]:=a) or circular references (a[1]:=b; b[1]:=c; c[1]:=a) that cannot be properly deallocated by simple reference counting.
Since all variables in harbour are stored inside some available tables (the eval stack, memvars table and array of static variables) then checking if the reference is still alive is quite easy and doesn't require any special treatment during memory allocation. Additionaly the garbage collector is scanning some internal data used by harbour objects implementation that also stores some values that can contain memory references. These data are used to initialize class instance variables and are stored in class shared variables.
In special cases when the value of a harbour variable is stored internally in some static area (at C or assembler level), the garbage collector will be not able to scan such values since it doesn't know their location. This could cause some memory blocks to be released prematurely. To prevent the premature deallocation of such memory blocks the static data have to store a pointer to the value created with hb_itemNew() function. Example:
static HB_ITEM s_item; // this item can be released by the GC
static PHB_ITEM pItem; // this item will be maintained correctly pItem = hb_itemNew( hb_param(1, IT_BLOCK) );
However, scanning of all variables can be a time consuming operation. It requires that all allocated arrays have to be traversed through all their elements to find more arrays. Also all codeblocks are scanned for detached local variables they are referencing. For this reason, looking for unreferenced memory blocks is performed during the idle states.
The idle state is a state when there is no real application code executed. For example, the user code is stopped for 0.1 of a second during INKEY(0.1) - Harbour is checking the keyboard only during this time. It leaves however quite enough time for many other background tasks. One such background task can be looking for unreferenced memory blocks.
Allocating memory -----------------
The garbage collector collects memory blocks allocated with hb_gcAlloc() function calls. Memory allocated by hb_gcAlloc() should be released with hb_gcFree() function.
The garbage collecting ----------------------
During scanning of unreferenced memory the GC is using a mark & sweep algorithm. This is done in three steps:
1) mark all memory blocks allocated by the GC with unused flag;
2) sweep (scan) all known places and clear unused flag for memory blocks that are referenced there;
3) finalize collecting by deallocation of all memory blocks that are still marked as unused and that are not locked.
To speed things up, the mark step is simplified by swapping the meaning of the unused flag. After deallocation of unused blocks all still alive memory blocks are marked with the same 'used' flag so we can reverse the meaning of this flag to 'unused' state in the next collecting. All new or unlocked memory blocks are automatically marked as 'unused' using the current flag, which assures that all memory blocks are marked with the same flag before the sweep step will start. See hb_gcCollectAll() and hb_gcItemRef()
Calling the garbage collector from harbour code -----------------------------------------------
The garbage collector can be called directly from the harbour code. This is usefull in situations where there is no idle states available or the application is working in the loop with no user interaction and there is many memory allocations. See HB_GCALL() for explanation of how to call this function from your harbour code.
See also
hb_gcAlloc(),hb_gcFree(),hb_gcCollectAll(),hb_gcItemRef(),HB_GCALL(), HB_IDLESTATE()
Index
Document

The idle states

Read me file for Idle States
Description
The idle state is the state of the harbour virtual machine when it waits for the user input from the keyboard or the mouse. The idle state is entered during INKEY() calls currently. All applications that don't use INKEY() function call can signal the idle states with the call of HB_IDLESTATE() function (or hb_idleState() on C level).
During idle states the virtual machine calls the garbage collector and it can call user defined actions (background tasks). It also releases the CPU time slices for some poor platforms that are not smart enough (Windows NT).
For defining the background tasks see the HB_IDLEADD() and HB_IDLEDEL() functions.
For direct call for background actions see HB_IDLESTATE() function.
For signaling the idle state from C code see the hb_idleState() API function.
See also
HB_IDLEADD(),HB_IDLEDEL()
Index
Document