# 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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sannybuilder.com/troubleshooting/errors/0122.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
