# Why does CPointer\<T\>.pointed not work

**URL:** <https://discuss.kotlinlang.org/t/why-does-cpointer-t-pointed-not-work/10488>\
**Category:** Native\
**Created:** [November 23, 2018, 2:25pm UTC](https://discuss.kotlinlang.org/t/why-does-cpointer-t-pointed-not-work/10488 "2018-11-23T14:25:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tommot1985](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/tommot1985/32/5785_2.png) [@tommot1985](https://discuss.kotlinlang.org/u/tommot1985)\
**Post date:** [November 23, 2018, 2:25pm UTC](https://discuss.kotlinlang.org/t/why-does-cpointer-t-pointed-not-work/10488/1 "2018-11-23T14:25:16Z")

</div>

Hi there,  
I’m playing around with SDL and am currently stuck.

```
package main

import kotlinx.cinterop.CPointer
import sdl.*

fun main(args: Array<String>) {
  SDL_Init(SDL_INIT_VIDEO)
  val window = SDL_CreateWindow("test", 10, 10, 800, 600, SDL_WINDOW_OPENGL)
  val surface: CPointer<SDL_Surface>? = SDL_GetWindowSurface(window)
  if (surface != null) {
    // the error is there -v
    SDL_FillRect(surface, null, SDL_MapRGB(surface.pointed.format, 255, 255, 255))
  }
  SDL_Delay(5000)
  SDL_DestroyWindow(window)
  SDL_Quit()
}

```

the compiler always quits with “unresolved reference: pointed” and I don’t understand why.

In the docs there is

```
val <T : CPointed> CPointer<T>.pointed : T

```

[https://kotlinlang.org/api/latest/jvm/stdlib/kotlinx.cinterop/-c-pointer/index.html#extension-properties](https://kotlinlang.org/api/latest/jvm/stdlib/kotlinx.cinterop/-c-pointer/index.html#extension-properties)  
and SDL\_Surface is a subtype of CPointed.  
What am I missing?

---

<div class="post-metadata">

**Author:** ![Jonathan.Haas](https://avatars.discourse-cdn.com/v4/letter/j/c68b51/32.png) [@Jonathan.Haas](https://discuss.kotlinlang.org/u/Jonathan.Haas)\
**Post date:** [November 29, 2018, 6:47pm UTC](https://discuss.kotlinlang.org/t/why-does-cpointer-t-pointed-not-work/10488/2 "2018-11-29T18:47:19Z")

</div>

You probably need to import the extension property. Something like

```kotlin
import kotlinx.cinterop.*

```

or

```kotlin
import kotlinx.cinterop.pointed

```

should probably work (untested)

---

<div class="post-metadata">

**Author:** ![tommot1985](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/tommot1985/32/5785_2.png) [@tommot1985](https://discuss.kotlinlang.org/u/tommot1985)\
**Post date:** [November 30, 2018, 6:48am UTC](https://discuss.kotlinlang.org/t/why-does-cpointer-t-pointed-not-work/10488/3 "2018-11-30T06:48:06Z")

</div>

Yeah that was it. I didn’t know that extensions had to be explicitly imported. The linter complains about wildcard imports so I avoid them… Well now it works, so thank you!

---

<div class="post-metadata">

**Author:** ![Wasabi375](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/wasabi375/32/4741_2.png) [@Wasabi375](https://discuss.kotlinlang.org/u/Wasabi375)\
**Post date:** [November 30, 2018, 6:53am UTC](https://discuss.kotlinlang.org/t/why-does-cpointer-t-pointed-not-work/10488/4 "2018-11-30T06:53:44Z")

</div>

> [@tommot1985](#):
>
> The linter complains about wildcard imports so I avoid them… Well now it works, so thank you!

There is a setting about that in intellij. You can set it to either use no wildcards, always use them or have more then x number of imports from the same package. You can also specify packages which are imported using wildcards only.
