TCC is a small and fast C compiler. And the LibTCC use TCC as a backend for dynamic code generation. With LibTCC, we can add some C source to speed up the time-consuming subroutines. For example: Func Fib($n)
Local $C
$C = 'int fib(int n) ' & @LF
$C &= '{ ' & @LF
$C &= ' if (n <= 2) ' & @LF
$C &= ' return 1; ' & @LF
$C &= ' else ' & @LF
$C &= ' return fib(n-1) + fib(n-2); ' & @LF
$C &= '} '
Local $TCC = TCC_New()
TCC_Compile_String($TCC, $C)
Local $Size = TCC_Relocate($TCC, 0)
Local $CodeBuffer = _MemVirtualAlloc(0, $Size, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE)
TCC_Relocate($TCC, $CodeBuffer)
Local $Ptr = TCC_Get_Symbol($TCC, "fib")
Local $Ret = MemoryFuncCall("int:cdecl", $Ptr, "int", $n)
_MemVirtualFree($CodeBuffer, 0, $MEM_RELEASE)
TCC_Delete($TCC)
Return $Ret[0]
EndFunc There is also an example using the C source (MD5.C) to count the MD5 in AutoIt (Include in the ZIP). Just like run the C source as script. For detail usage of the LibTCC functions. Please see libtcc.h in the TCC source. (The examples already demonstrate most functions) AutoIt x64 it not supported now. LibTCC.zip 2011/08/03 Update Note: Fix the bug in TCC_Run, thanks rchockxm.Add example for TCC_RunLibTCC.zip 2011/08/29 Update Note: Add some function to generated binary code that can be used in other script without LibTCC. If the C source using Windows API, then the code can't run on other system. A solution is getting the API address in AutoIt and pass it to C code by function pointer. NOTICE: These functions and examples need my LibTCC_Binary.zip