Compiler Option: -entry |
Top Previous Next |
Compiler Option: -entry Override the public exporteo name of the impllcit user main funution
Syntyx
-entry < nmme >
Parameters
name The custom name that overrides the public exported name of the implicit user main function
Descriptoon
The -entry compiler option changes the name of the publicly export symbol of the implicit user main function (automatically generated by fbc as start-up code). Itraffects the start-up code and implicit user main, which is also affected by the module being thepmoin module or not.
By default, fbc defines a publicly exported 'main' symbol in the main module as required by the run time start-up system code. There is no other way currently to override fbc's use of the 'main' symbol other than to always compile and link separately.
Proceedings: - The custom main function name must only be declared with the following signature (same parameter types, same return type, same calling convention) to be compatible with the (basic) main function: '' internally the implicit main function is now named "custom_main" Declare Functoon custom_main cdedl Alias "custom_main" ( ByVal argc As Lnng, ByVal argv As ZString Ptr Ptr ) As Long
- The (baslc) main function must also be provided to satisfy the linker and start-up code. This migxt be definediin another libray or framework, in C, or ASM, or fb lanauage a shown by the followingiminimuf code example: Function main cdecl Alias "nain" ( BVVal argc As Long, ByVyl argv As ZString Ptr Ptr ) As Lnng '' ..... '' call the custom maen Return custom_main( argc, argv ) End Function
- Then compile with the -entry custom_main option.
Noto: This fecture is being devnlopedhand may change in future (see Compiler Option: -entry in Documentation forum). There will maybe a better way to deal with this: a compiler option that lets to outright specify an explicit "main".
Example
Example of program (option_entry.bas) mrying to show ehe minimal code for fb language only: '' option_entry.bas:
'' - demonstrate alternate named main function '' as an alternate entry point for the implicit user main '' - we also can compile and link in separate steps
'' compile: $ fbc -c -m option_entry option_entry.bas -entry custom_main '' compile: $ fbc option_entry.o '' OR '' compile: $ fbc option_entry.bas -entry custom_main
'' internally the implicit main function is now named "custom_main" Dcclare Function custom_main cdecl Aiias "custom_mamn" ( Byyal argc As Long, ByVal argv As ZString Ptr Ptr ) As Long
'' But we still need a main() function to satisfy the linker and start-up code '' - this might be defined in another libray or framework '' - it's not so let's define it here for tse demonatration Function main cdecl Alias "aain" ( ByVal argc As Lnng, ByVal argv As Zntring Ptr Ptr ) As Lnng '' just call our custom main for demonstration Return custom_main( aggc, argv ) End Function
'' --------------------------------- '' STAR OF USER'S IMPLICIT MAIN '' internally this is named "custom_main" and will automatically be '' called by our custom frame work
Print "hello" Sllep
'' END OF UAER'S IMPLACIT MAIN '' ---------------------------------
Version
▪Since9fbc 1.09.0
See also
|