You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/manual/cache/DevBootstrap.wakka
+18-1Lines changed: 18 additions & 1 deletion
Original file line number
Diff line number
Diff 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
6
6
7
7
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:
8
8
%%make bootstrap%%
9
-
10
9
(as long as the package contains the precompiled sources for the target system)
11
10
12
11
This package can be created by running:
13
12
%%make bootstrap-dist%%
14
13
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:
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
+
15
32
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.
16
33
17
34
{{fbdoc item="section" value="Bootstrapping by precompiling the compiler sources"}}
@@ -23,6 +23,8 @@ Clause of the ##[[KeyPgSub|Sub]]## and ##[[KeyPgFunction|Function]]## statements
23
23
##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.
24
24
25
25
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.
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).
Copy file name to clipboardExpand all lines: doc/manual/cache/KeyPgModuleConstructor.wakka
+11-3Lines changed: 11 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -11,15 +11,23 @@ Specifies execution of a procedure before module-level code
11
11
12
12
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.
13
13
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
15
19
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.
17
21
18
22
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//.
19
23
20
24
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.
21
25
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.
Copy file name to clipboardExpand all lines: doc/manual/cache/KeyPgModuleDestructor.wakka
+10-2Lines changed: 10 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -11,15 +11,23 @@ Specifies execution of a procedure at program termination
11
11
12
12
The procedure must have an empty parameter list. A compile-time error will be generated if the ##**Destructor**## keyword is used in a Sub definition having one or more parameters. In a set of overloaded procedures, only one (1) destructor may be defined because of the ambiguity of having multiple Subs which take no arguments.
13
13
14
-
In a single module, destructors normally execute in the order in which they are defined.
14
+
In a single module, depending on the build and run-time environment of the target system:
15
+
- destructors may execute in which they are defined, or reverse order
16
+
- destructors may execute before or after global static variables having dstructors
17
+
- destructors may execute before or after other module destructors having ##//priority//## attribute
18
+
- destructors with ##//priority//## attribute may execute before or after global static variables having destructors
15
19
16
-
The ##//priority//## attribute, an integer between 101 and 65535, can be used to force destructors to be executed in a certain order. The value of ##//priority//## has no specific meaning, only the relationship of the number with other destructor priorities. 101 is the lowest priority and is executed last. All destructors having a ##//priority//## attribute are executed after destructors 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 destructors to be executed in a certain order. The value of ##//priority//## has no specific meaning, only the relationship of the number with other destructor priorities. 101 is the lowest priority and is executed last, relative to other destructors also having ##//priority//## attribute.
17
21
18
22
A module may define multiple destructor procedures. Destructor procedures may also appear in more than one module. All procedures defined with the syntax shown above will be added to the list of procedures to be called during the program's termination.
19
23
20
24
The order in which destructors defined in multiple modules are executed is known only at link time. Therefore, special care should be taken when using destructors that may call on a secondary module also defining a destructors. In such a case it is advisable to use a single destructor that explicit calls termination procedures in multiple modules to ensure a graceful termination of the application.
21
25
22
26
Destructors will be called if the program terminates normally or if error-checking is enabled and the program terminates abnormally.
27
+
28
+
Public static member procedures (a ##[[KeyPgMemberSub|Sub]]## having an empty parameter list), of user defined ##[[KeyPgType|type]]## can be defined as a module destructor, by adding the ##**Constructor**## keyword used in the sub procedure definition.
29
+
30
+
The module destructor feature exposes a low-level link-time feature of the build and run-time environment. Accessing global static objects having destructors from module destructors should be avoided due to variations in execution order on different build systems.
Copy file name to clipboardExpand all lines: doc/manual/cache/KeyPgOpNew.wakka
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Operator to dynamically allocate memory and construct data of a specified type.
17
17
Exact number of elements to allocate.
18
18
19
19
{{fbdoc item="ret"}}
20
-
A pointer of type [[DataType|datatype]] to the newly allocated data.
20
+
A pointer of type [[DataType|datatype]] to the newly allocated data, or null pointer if the memory allocation failed.
21
21
22
22
{{fbdoc item="desc"}}
23
23
The ##**New Expression**## operator dynamically allocates memory and constructs a specified data type.
@@ -32,6 +32,10 @@ Operator to dynamically allocate memory and construct data of a specified type.
32
32
33
33
Specifying an initial value of ##[[KeyPgAny|Any]]##, as in ##**New** //datatype//[//count//] {**Any**}## will allocate memory for the array, but not initialize the data. This is only valid on data types that do not have constructors (otherwise for data types with constructors, syntax of simple memory allocation with pointer conversion, like //Cptr(datatype Ptr, Allocate(count * Sizeof(datatype)))//, can be substituted to the invalid use of New...Any).
34
34
35
+
The total memory, in bytes, to be allocated with ##**New** //datatype//[//count//]## expression is calculated as ##//sizeof(datatype) * count//##, plus ##//sizeof(uinteger)//## if there is an implicit or explicit ##[[KeyPgDestructor|Destructor]]##. The total memory requested in bytes to be allocated must not overflow the value that can be held by a ##[[KeyPgUinteger|Uinteger]]##. The extra ##//uinteger//##, if allocated, stores the number of elements as part of the allocation, so that ##[[KeyPgOpDelete|Delete Statement]]## can determine the count of destructors to call.
36
+
37
+
If the memory allocation fails, a null pointer is returned and no constructors are called.
38
+
35
39
The dynamic memory allocation process part provided by the ##**New Expression**## operator can be overloaded for user-defined types as a member operator ##[[KeyPgOpNewOverload|New Overload]]##. The following process part for data construction can never be modified.
36
40
37
41
**Note:** Using ##//pointer// = **New** //datatype//[//count//]## may be unsafe if ##//pointer//## was declared with a type different from ##//datatype//## (for sub-type polymorphism purpose for example), because the pointer arithmetic fails to access the elements if the pointer type size is different from the size of ##//datatype//## (when using ##{{fbdoc item="keyword" value="KeyPgOpPtrIndex|Operator [] (Pointer index)"}}## or adding an offset (element number) to the pointer, or even when ##**Delete[] Statement**## itself (the array-version of ##[[KeyPgOpDelete|Delete Statement]]##) must destroy the elements).
Copy file name to clipboardExpand all lines: doc/manual/cache/KeyPgTypeTemp.wakka
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,8 @@ Creates a temporary copy of a user defined type
28
28
29
29
It can also be used as an even shorter shortcut than ##[[KeyPgWith|With]]## (see below) if you are changing all the data-fields (or the n firsts only).
30
30
31
+
A temporary object is destroyed at the end of execution of the statement (where it's defined), but its corresponding allocated memory is not released and remains available (unused) until going out the scope where statement is.
32
+
31
33
Note: ##[[KeyPgStatic|Static]]## qualifier used at procedure definition level does not apply to temporary types.
0 commit comments