> For the complete documentation index, see [llms.txt](https://docs.sannybuilder.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sannybuilder.com/troubleshooting/errors/0122.md).

# 0122: A non-static function can't be called by name

Compiler found a [foreign function](/language/functions.md#foreign-functions) call, but this function is non-static, i.e. it does not have an address as part of its declaration. It is an error to call such function using the name:

```swift
function CStats__GetStatType<cdecl>(statId: int): int
int value = CStats__GetStatType(0xDEADD0D0) // error: A non-static function CStats__GetStatType can not
```

#### Possible solutions:

* Call the non-static foreign function using a function pointer variable:

```swift
function CStats__GetStatType<cdecl>(statId: int): int
CStats__GetStatType method // define a pointer to function Destroy
...
method = 0x400000 // function is located at 0x400000
int value = method(0xDEADD0D0) // call function using the pointer
```

* if the function address is known ahead of time, provide the address inside angle brackets:

```swift
function CStats__GetStatType<cdecl,0x558E30>(statId: int): int // static foreign function
int value = CStats__GetStatType(0xDEADD0D0) // OK
```
