Skip to content

Commit 5ee8f12

Browse files
authored
Merge pull request #108 from jayrm/fbdoc
fbdoc: wiki snapshot 2018-10-08
2 parents 945df0e + 115b42d commit 5ee8f12

24 files changed

+484
-125
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Version 1.06.0
88
- boolean: don't allow NEG unary op '-' on boolean data types
99
- All fb RTL functions are checked for CONSTness, CONST qualifiers added to fb rtlib built-in prototypes (sf.net #727)
1010
- WSTRING can be a return type, but only for prototypes (DECLARE) and function pointers, this allows getting PROCPTR() of all fb built-in run time functions
11+
- multiline comments are parsed in -lang fblite|qb|deprecated as in -lang fb for consistency
1112

1213
[added]
1314
- Name mangling of Long parameters on Win64 are mangled to C++ int by default and to C++ long with a modifier in the form 'as [u]long alias "long"'. The data type size is still 32bit but allows calling external C++ library expecting a C++ long.

doc/manual/cache/CatPgDddefines.wakka

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Preprocessor symbols defined by the compiler.
7070
Defined to either ##"gas"## or ##"gcc"## depending on [[CompilerOptgen|-gen]].
7171
=={{fbdoc item="keyword" value="KeyPgDdfbgcc|__FB_GCC__"}}==
7272
True (##-1##) if -gen gcc is used, false (##0##) otherwise.
73+
=={{fbdoc item="keyword" value="KeyPgDdfbgui|__FB_GUI__"}}==
74+
True (##-1##) if the ##"-s gui"## switch was used, false (##0##) otherwise.
7375
=={{fbdoc item="keyword" value="KeyPgDdFBMain|__FB_MAIN__"}}==
7476
Defined if compiling a module with an entry point.
7577
=={{fbdoc item="keyword" value="KeyPgDdfbdebug|__FB_DEBUG__"}}==

doc/manual/cache/CatPgFullIndex.wakka

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Alphabetical listing of keywords, macros and procedures.
3030
- {{fbdoc item="keyword" value="KeyPgDdfbfpu|__FB_FPU__"}}
3131
- {{fbdoc item="keyword" value="KeyPgDdfbfreebsd|__FB_FREEBSD__"}}
3232
- {{fbdoc item="keyword" value="KeyPgDdfbgcc|__FB_GCC__"}}
33+
- {{fbdoc item="keyword" value="KeyPgDdfbgui|__FB_GUI__"}}
3334
- {{fbdoc item="keyword" value="KeyPgDdfblang|__FB_LANG__"}}
3435
- {{fbdoc item="keyword" value="KeyPgDdfblinux|__FB_LINUX__"}}
3536
- {{fbdoc item="keyword" value="KeyPgDdFBMain|__FB_MAIN__"}}

doc/manual/cache/CatPgFunctIndex.wakka

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,10 @@ List of ""FreeBASIC"" keywords sorted by the function they perform.
408408
- {{fbdoc item="keyword" value="KeyPgDdfbdos|__FB_DOS__"}}
409409
- {{fbdoc item="keyword" value="KeyPgDdfberr|__FB_ERR__"}}
410410
- {{fbdoc item="keyword" value="KeyPgDdfbfpmode|__FB_FPMODE__"}}
411-
- {{fbdoc item="keyword" value="KeyPgDdfbfpu|__FB_FPFPU__"}}
411+
- {{fbdoc item="keyword" value="KeyPgDdfbfpu|__FB_FPU__"}}
412412
- {{fbdoc item="keyword" value="KeyPgDdfbfreebsd|__FB_FREEBSD__"}}
413413
- {{fbdoc item="keyword" value="KeyPgDdfbgcc|__FB_GCC__"}}
414+
- {{fbdoc item="keyword" value="KeyPgDdfbgui|__FB_GUI__"}}
414415
- {{fbdoc item="keyword" value="KeyPgDdfblang|__FB_LANG__"}}
415416
- {{fbdoc item="keyword" value="KeyPgDdfblinux|__FB_LINUX__"}}
416417
- {{fbdoc item="keyword" value="KeyPgDdFBMain|__FB_MAIN__"}}

doc/manual/cache/CompilerOpts.wakka

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ Sets the executable subsystem
1010

1111
{{fbdoc item="desc"}}
1212
The ##-s## compiler option specifies the executable subsystem. Allowed subsystems are ##gui## and ##console## (by default, ##console## is used). Specifying a ##gui## subsystem prevents the console window from appearing behind the program window.
13+
14+
The intrinsic macro ##[[KeyPgDdfbgui|__FB_GUI__]]## is set to non-zero (-1) if the option with ##gui## as subsystem was specified, and set to zero (0) otherwise.
1315

1416
{{fbdoc item="target"}}
1517
- Supported on Windows and Cygwin only.
1618

1719
{{fbdoc item="see"}}
20+
- ##[[KeyPgDdfbgui|__FB_GUI__]]##
1821
- [[CompilerCmdLine|Using the Command Line]]
1922

2023
{{fbdoc item="back" value="CatPgCompOpt|Compiler Options"}}

doc/manual/cache/DevBootstrap.wakka

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,29 @@ fbc is written in FB itself, so you need a working fbc to build a new fbc. How t
66

77
The ""FreeBASIC-x.xx.x-source-bootstrap"" package contains the FB sources plus precompiled compiler sources, for multiple targets. After extracting, this can be built without requiring an existing fbc:
88
%%make bootstrap%%
9-
109
(as long as the package contains the precompiled sources for the target system)
1110

1211
This package can be created by running:
1312
%%make bootstrap-dist%%
1413

14+
{{fbdoc item="section" value="Bootstrapping by creating and using a bootstrap package"}}
15+
16+
1) On a system with a working fbc compiler, create the bootstrap package:
17+
%%make bootstrap-dist%%
18+
creates ##FreeBASIC-x.xx.x-source-bootstrap.tar.xz##
19+
20+
1) Take the bootstrap package to the new system and use it to build the bootstrap compiler:
21+
%%cd ~
22+
tar xf ~/FreeBASIC-x.xx.x-source-bootstrap.tar.xz
23+
cd FreeBASIC-x.xx.x-source-bootstrap
24+
make bootstrap
25+
%%
26+
27+
1) On the new system, assuming sources are in ~/fbc, use the bootstrap compiler to build fbc for the new system
28+
%%cd ~/fbc
29+
make 'FBC=~/FreeBASIC-x.xx.x-source-bootstrap/bin/fbc -i ~/FreeBASIC-x.xx.x-source-bootstrap/inc'
30+
%%
31+
1532
Doing ##make bootstrap-dist##, taking the package to the target system, and then doing ##make bootstrap## can replace the manual steps below, as long as the target is already supported by these commands in the FB makefile.
1633

1734
{{fbdoc item="section" value="Bootstrapping by precompiling the compiler sources"}}

doc/manual/cache/KeyPgAlias.wakka

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{fbdoc item="title" value="ALIAS"}}----
2-
Clause of the ##[[KeyPgSub|Sub]]## and ##[[KeyPgFunction|Function]]## statements that provides an alternate internal name
2+
Clause of the ##[[KeyPgSub|Sub]]## and ##[[KeyPgFunction|Function]]## statements that provides an alternate internal name.
33

44
{{fbdoc item="syntax"}}##
55
[[[KeyPgDeclare|declare]]] { [[KeyPgSub|sub]] | [[KeyPgFunction|function]] } //usablename// **Alias "//alternatename//"** (...)
@@ -23,6 +23,8 @@ Clause of the ##[[KeyPgSub|Sub]]## and ##[[KeyPgFunction|Function]]## statements
2323
##Alias## is commonly used for procedures in libraries written in other languages when such procedure names are valid in the other language but invalid in BASIC. When using ##Alias## with ##[[KeyPgDeclare|Declare]]##, only the alternate name is used by the linker.
2424

2525
Differently from normal procedure names, ##Alias## does not change the case of the alternate name, so it is useful when external code requires an exported function with a particular name or with a particular case.
26+
27+
##Alias## can also be used as modifier that specifies an alternate mangling for procedure parameters. For example ##extern ""c+""""+"" : declare sub proc( byval as long **alias "long"** ) : end extern##. This form of ##Alias## can only be used as in //##[unsigned] [u]long alias "long"##//. The specific purpose is to allow FreeBASIC to call external ""c+""""+"" procedures (on win-64) requiring a 32-bit ##'long int'## type. Usage of ##Alias## in this way affects win-64 targets only, and is ignored on all other targets.
2628

2729
{{fbdoc item="ex"}}
2830

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{fbdoc item="title" value="__FB_GUI__"}}----
2+
Intrinsic define (macro value) set by the compiler
3+
4+
{{fbdoc item="syntax"}}##
5+
""__FB_GUI__""
6+
##
7+
{{fbdoc item="desc"}}
8+
##""__FB_GUI__""## indicates if the executable subsystem option '-s gui' was specified on the command line at the time of compilation.
9+
10+
Returns non-zero (-1) if the executable subsystem option '-s gui' was specified. Returns zero (0) otherwise (no executable subsystem option specified, or executable subsystem option '-s console' specified).
11+
12+
{{fbdoc item="ex"}}
13+
{{fbdoc item="filename" value="examples/manual/defines/fbgui.bas"}}%%(freebasic)
14+
#if __FB_GUI__ <> 0
15+
#print Executable subsystem: gui
16+
#else
17+
#print Executable subsystem: console
18+
#endif
19+
%%
20+
{{fbdoc item="target"}}
21+
- Supported on Windows and Cygwin only.
22+
23+
{{fbdoc item="diff"}}
24+
- New to ""FreeBASIC""
25+
26+
{{fbdoc item="see"}}
27+
- [[CompilerOpts|Compiler Option: -s]]
28+
29+
{{fbdoc item="back" value="CatPgDddefines|Intrinsic Defines"}}

doc/manual/cache/KeyPgErase.wakka

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Statement to erase arrays
1515
Using ##**Erase**## on a fixed-length array resets all elements without freeing the allocated memory.
1616
In case of objects, there is destruction then re-construction.
1717

18-
Using ##**Erase**## on a variable-length array (array already sized) frees the memory used by the element data (does not allow to after resize it with a different number of dimensions).
18+
Using ##**Erase**## on a variable-length array (array already sized) frees the memory allocated for the array elements, but the array remains declared at its same scope level (with the same datatype and number of dimensions).
1919
In case of objects, there is destruction before freeing memory.
2020

2121
{{fbdoc item="ex"}}

doc/manual/cache/KeyPgModuleConstructor.wakka

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,23 @@ Specifies execution of a procedure before module-level code
1111

1212
The procedure must have an empty parameter list. A compile-time error will be generated if the ##**Constructor**## keyword is used in a Sub definition having one or more parameters. In a set of overloaded procedures, only one (1) constructor may be defined because of the ambiguity of having multiple Subs which take no arguments.
1313

14-
In a single module, constructors normally execute in the reverse order in which they are defined.
14+
In a single module, depending on the build and run-time environment of the target system:
15+
- constructors may execute in which they are defined, or reverse order
16+
- constructors may execute before or after global static variables having constructors
17+
- constructors may execute before or after other module constructors having ##//priority//## attribute
18+
- constructors with ##//priority//## attribute may execute before or after global static variables having constructors
1519

16-
The ##//priority//## attribute, an integer between 101 and 65535, can be used to force constructors to be executed in a certain order. The value of ##//priority//## has no specific meaning, only the relationship of the number with other constructor priorities. 101 is the highest priority and is executed first. All constructors having a ##//priority//## attribute are executed before constructors with no attribute. The priority value of 65535 is the same as not assigning a priority value.
20+
The ##//priority//## attribute, an integer between 101 and 65535, can be used to force constructors to be executed in a certain order, relative to other constructors also having ##//priority//## attribute. The value of ##//priority//## has no specific meaning, only the relationship of the number with other constructor priorities. 101 is the highest priority and is executed first, relative to other constructors also having ##//priority//## attribute.
1721

1822
A module may define multiple constructor procedures, and multiple modules may define additional constructors provided no two ##[[KeyPgPublic|Public]]## constructors share the same //procedure_name//.
1923

2024
When linking with modules that also define constructors, the order of execution is not guaranteed at link-time unless the ##//priority//## attribute is used. Therefore, special care should be taken when using constructors that may call on a secondary module also defining a constructor. In such a case it is advisable to use a single constructor that explicitly calls initialization procedures in those modules.
2125

22-
**Note:** A public static member procedure (Sub having empty parameter list) can also be defined as module constructor (also with the ##**Constructor**## keyword only used in Sub definition).
26+
Public static member procedures (a ##[[KeyPgMemberSub|Sub]]## having an empty parameter list), of user defined ##[[KeyPgType|type]]## can be defined as a module constructor, by adding the ##**Constructor**## keyword used in the sub procedure definition.
27+
28+
Initialization of static simple numeric type variables, that have a value that can be determined at compile time (for example, default zero, constants, pointers to static objects, pointers to functions, etc), are initialized before any code is executed. These values are part of the executable image and have an initial value when the executable is loaded in to memory. Trivial static globals where no code is needed to initialize, are guaranteed to be initialized and can be reliably used in all code, including global static object constructors and module constructors.
29+
30+
The module constructor feature exposes a low-level link-time feature of the build and run-time environment. Accessing global static objects having constructors from module constructors should be avoided due to variations in execution order on different build systems.
2331

2432
{{fbdoc item="ex"}}
2533
{{fbdoc item="filename" value="examples/manual/procs/mod-ctor.bas"}}%%(freebasic)

0 commit comments

Comments
 (0)