# Cchar != eltype(Cstring)

**URL:** <https://discourse.julialang.org/t/cchar-eltype-cstring/21634>\
**Category:** Internals & Design\
**Tags:** strings\
**Created:** [March 8, 2019, 2:26pm UTC](https://discourse.julialang.org/t/cchar-eltype-cstring/21634 "2019-03-08T14:26:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nstiurca](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@nstiurca](https://discourse.julialang.org/u/nstiurca)\
**Post date:** [March 8, 2019, 2:26pm UTC](https://discourse.julialang.org/t/cchar-eltype-cstring/21634/1 "2019-03-08T14:26:54Z")

</div>

So I am wrapping some C libraries in Julia, and noticed that `Cchar` maps to `Int8`, whereas `Cstring` has an `eltype` of `UInt8`, calling `pointer(some_cstring)` returns a `Ptr{UInt8}`. This inconsistency seems rather odd. Furthermore, the documentation for `Cstring` states that “A C-style string composed of the native character type `Cchar`s” which I would expect, but doesn’t seem to match the actual implementation.

So is this a bug with how `Cstring` is implemented? With how it’s documented? Maybe it’s intentionally different? (buty why?) Maybe I’m just missing something?

I know that `char` in C is not defined to be either signed nor unsigned but rather left to the implementation, so maybe this is related to that. I’m on Linux x64 for what it’s worth.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [March 9, 2019, 4:10pm UTC](https://discourse.julialang.org/t/cchar-eltype-cstring/21634/2 "2019-03-09T16:10:05Z")

</div>

Probably just an oversight. Would you mind filing an issue?

---

<div class="post-metadata">

**Author:** ![nstiurca](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@nstiurca](https://discourse.julialang.org/u/nstiurca)\
**Post date:** [March 17, 2019, 11:10am UTC](https://discourse.julialang.org/t/cchar-eltype-cstring/21634/3 "2019-03-17T11:10:56Z")

</div>

> <https://github.com/JuliaLang/julia/issues/31381>
>
> The documentation claims, and my intuition would also suggest, that \`eltype(Cstr…ing)\` should be \`Cchar\`. I \[originally asked about this on discourse\](https://discourse.julialang.org/t/cchar-eltype-cstring/21634), and @StefanKarpinski suggested it's probably just an oversight. Note also that \`pointer(Cstring(C\_NULL))\` returns \`Ptr{UInt8}\` rather than \`Ptr{Cchar}\` ie \`Ptr{Int8}\`.
> 
> Note I am on Linux x86\_64, and I know \`char\` can be unsigned on some systems.
> 
> \`\`\`
> \_
> \_ \_ \_(\_)\_ | Documentation: https://docs.julialang.org
> (\_) | (\_) (\_) |
> \_ \_ \_| |\_ \_\_ \_ | Type "?" for help, "\]?" for Pkg help.
> | | | | | | |/ \_\` | |
> | | |\_| | | | (\_| | | Version 1.1.0 (2019-01-21)
> \_/ |\\\_\_'\_|\_|\_|\\\_\_'\_| | Official https://julialang.org/ release
> |\_\_/ |
> 
> julia\> s = Cstring(C\_NULL)
> Cstring(0x0000000000000000)
> 
> julia\> pointer(s)
> Ptr{UInt8} @0x0000000000000000
> 
> julia\> eltype(s)
> UInt8
> 
> julia\> Cchar
> Int8
> 
> \`\`\`
