Code: Select all
dim u8 as ubyte
dim s8 as byte
If there's not already a way to do this, please consider this post to be a feature request.
Code: Select all
dim u8 as ubyte
dim s8 as byte
The fb run time system (which uses c run time system), expects that by the time the user portion of the program is loaded and ready to run, certain initialization will be done and certain facilities will be available: stack alignment, memory management, thread management, command line arguments, console / file redirection, etc, are all expected to be initialized to allow the rest of the run time system to work. And all of fb's built-in commands and features usually require some parts of the run time system to be up and running. Since most user programs tend to need the same kinds of facilities, there is some minimal amount of start-up code that gets added to all executables. Automatically including / excluding only parts of the start-up would be hard to do since the run-time system startup and support code is not written in a way that can arbitrarily select which facilities to support or not.
Code: Select all
'' minimal executable example for windows 32-bit
'' should produce a 2048 byte excecutable
''
'' compile with:
'' fbc -c minimal.bas
''
'' link with:
'' ld minimal.o -s -L d:/fbc/lib/win32 -l kernel32 -o minimal.exe
#include "windows.bi"
sub mainCRTStartup cdecl alias "mainCRTStartup" ()
dim u8 as ubyte
dim s8 as byte
ExitProcess(0)
end sub
Code: Select all
#include "windows.bi"
#include "crt.bi"
#ifdef __FB_64BIT__
#define CallConvention
#else
#define CallConvention Cdecl
#endif
Sub wmain CallConvention Alias "wmain" ()
Dim As Integer i
For i=1 To 3
printf !"This is a test.\n"
Next i
ExitProcess(0)
End Sub
Code: Select all
\FreeBASIC\fbc32 -nodeflibs -c SmallExe.bas
IF EXIST C:\msys64\mingw32\bin\objcopy.exe C:\msys64\mingw32\bin\objcopy.exe --remove-section .fbctinf --remove-section .ctors SmallExe.o
\FreeBASIC\bin\win32\ld -e _wmain -subsystem console -o SmallExe.exe SmallExe.o -L\FreeBASIC\lib\win32 -lkernel32 -luser32 -lgdi32 -lmsvcrt -s
\FreeBASIC\fbc64 -nodeflibs -c SmallExe.bas -o SmallExe64.o
IF EXIST C:\msys64\mingw64\bin\objcopy.exe C:\msys64\mingw64\bin\objcopy.exe --remove-section .rdata$zzz --remove-section .ctors --remove-section .fbctinf SmallExe64.o
\FreeBASIC\bin\win64\ld -e wmain -subsystem console -o SmallExe64.exe SmallExe64.o -L\FreeBASIC\lib\win64 -lkernel32 -luser32 -lgdi32 -lmsvcrt -s
Code: Select all
SmallExe.exe : 2560 Bytes
SmallExe64.exe : 2048 Bytes