# Compilation module

The **Compilation** module groups together intrinsics that report on how --- and from where --- the running code was built. Most of its members are *compile-time* intrinsics: they do not look anything up at run time but instead embed a literal value into the compiled code at the point of the call, recording the surrounding project, component, procedure, or source file as it stood when the compiler ran.

## Build identity

[**CompilerVersion**](/tB/Modules/Compilation/CompilerVersion.md) returns the build number of the twinBASIC compiler that produced the running code, and [**ProcessorArchitecture**](/tB/Modules/Compilation/ProcessorArchitecture.md) returns a [**VbArchitecture**](/tB/Modules/Constants/VbArchitecture.md) constant --- **vbArchWin32** or **vbArchWin64** --- identifying whether the binary was built for 32-bit or 64-bit execution. Together they characterise *which* compiler emitted the running code and *what kind* of process it is running in.

```tb check_build
Debug.Print "twinBASIC build #" & CompilerVersion()
If ProcessorArchitecture() = vbArchWin64 Then
    Debug.Print "64-bit process"
Else
    Debug.Print "32-bit process"
End If
```

## Lexical context

The `Current...` family records the source location of the call site as a literal string, captured when the source is compiled. [**CurrentProjectName**](/tB/Modules/Compilation/CurrentProjectName.md) names the project (executable or library) that owns the call, [**CurrentComponentName**](/tB/Modules/Compilation/CurrentComponentName.md) names the enclosing module, class, or form, [**CurrentProcedureName**](/tB/Modules/Compilation/CurrentProcedureName.md) names the surrounding **Sub**, **Function**, or **Property**, and [**CurrentSourceFile**](/tB/Modules/Compilation/CurrentSourceFile.md) returns the full path of the source file as it was on the build machine. For COM classes, [**CurrentComponentCLSID**](/tB/Modules/Compilation/CurrentComponentCLSID.md) returns the GUID supplied by the class's [`[ClassId(...)]`](/tB/Core/Attributes.md#classid) attribute, or the all-zero GUID when none is set.

Because each value is fixed at compile time, wrapping a call in a helper records the *helper's* name rather than its caller's. These intrinsics are most useful in diagnostic output --- logging, tracing, assertions --- where they replace hard-coded identifier strings that would otherwise drift as code is renamed.

```tb check_build
Public Sub Log(Message As String)
    Debug.Print CurrentProjectName() & "!" & _
                CurrentComponentName() & "." & _
                CurrentProcedureName() & ": " & Message
End Sub
```

## Compiler hints

[**UnrollLoop**](/tB/Modules/Compilation/UnrollLoop.md) is a statement rather than a value: placed as the first statement in a loop's body, it asks the [LLVM compiler](/LLVM/Getting-Started.md) to unroll that loop for speed. It does not change what the loop does, and code that is not compiled with LLVM ignores it.

## Members

- [CompilerVersion](/tB/Modules/Compilation/CompilerVersion.md) -- returns the twinBASIC compiler version number
- [CurrentComponentCLSID](/tB/Modules/Compilation/CurrentComponentCLSID.md) -- returns the Class ID (CLSID) of the current class
- [CurrentComponentName](/tB/Modules/Compilation/CurrentComponentName.md) -- returns the name of the current component (module or class)
- [CurrentProcedureName](/tB/Modules/Compilation/CurrentProcedureName.md) -- returns the name of the procedure in which the function is called
- [CurrentProjectName](/tB/Modules/Compilation/CurrentProjectName.md) -- returns the name of the current project
- [CurrentSourceFile](/tB/Modules/Compilation/CurrentSourceFile.md) -- returns the full path of the current source file
- [ProcessorArchitecture](/tB/Modules/Compilation/ProcessorArchitecture.md) -- returns the processor architecture of the running application
- [UnrollLoop](/tB/Modules/Compilation/UnrollLoop.md) -- asks the LLVM compiler to unroll the loop that contains it
