# Cxx: calling icxx with a string interpolation results in a cryptic BoundsError

**URL:** <https://discourse.julialang.org/t/cxx-calling-icxx-with-a-string-interpolation-results-in-a-cryptic-boundserror/31508>\
**Category:** General Usage\
**Tags:** cxx\
**Created:** [November 25, 2019, 9:55pm UTC](https://discourse.julialang.org/t/cxx-calling-icxx-with-a-string-interpolation-results-in-a-cryptic-boundserror/31508 "2019-11-25T21:55:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GlenHenshaw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/glenhenshaw/32/5269_2.png) [@GlenHenshaw](https://discourse.julialang.org/u/GlenHenshaw)\
**Post date:** [November 25, 2019, 9:55pm UTC](https://discourse.julialang.org/t/cxx-calling-icxx-with-a-string-interpolation-results-in-a-cryptic-boundserror/31508/1 "2019-11-25T21:55:09Z")

</div>

This code used to work for me:

```
foo = @cxxnew makefoo();
icxx"$foo->bar = 5;"

```

But it now throws a rather cryptic error:

`ERROR: BoundsError: attempt to access 36-element Array{Tuple{AbstractString,Symbol,Int64,Int64,Bool},1} at index [37]`

which might be a result of interpolating $foo into the icxx command, as the string “$foo-\>bar = 5” happens to be 36 characters long after the interpolation? But I can’t tell.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 26, 2019, 9:28pm UTC](https://discourse.julialang.org/t/cxx-calling-icxx-with-a-string-interpolation-results-in-a-cryptic-boundserror/31508/2 "2019-11-26T21:28:19Z")

</div>

A full backtrace would be helpful here.

---

<div class="post-metadata">

**Author:** ![GlenHenshaw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/glenhenshaw/32/5269_2.png) [@GlenHenshaw](https://discourse.julialang.org/u/GlenHenshaw)\
**Post date:** [November 26, 2019, 9:45pm UTC](https://discourse.julialang.org/t/cxx-calling-icxx-with-a-string-interpolation-results-in-a-cryptic-boundserror/31508/3 "2019-11-26T21:45:02Z")

</div>

```julia
Stacktrace:
 [1] getindex(::Array{Tuple{AbstractString,Symbol,Int64,Int64,Bool},1}, ::Int64) at ./array.jl:728
 [2] #s37#70 at /Users/glenhenshaw/.julia/packages/Cxx/UZsgx/src/cxxstr.jl:705 [inlined]
 [3] #s37#70(::Any, ::Any, ::Any, ::Any) at ./none:0
 [4] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any,N} where N) at ./boot.jl:524
 [5] RMRCsetup(::Manipulator, ::Function, ::Array{Float64,1}, ::Float64, ::Float64, ::Float64, ::Float64, ::Array{Constraint,1}, ::Float64, ::Float64) at /Users/glenhenshaw/Code/RSGS/PositionControl/RMRC.jl:78
 [6] RMRCsetup at /Users/glenhenshaw/Code/RSGS/PositionControl/RMRC.jl:56 [inlined]
 [7] sam_trajectory() at /Users/glenhenshaw/Code/RSGS/PositionControl/SamTrajectory.jl:117
 [8] top-level scope at REPL[4]:1

```

---

<div class="post-metadata">

**Author:** ![GlenHenshaw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/glenhenshaw/32/5269_2.png) [@GlenHenshaw](https://discourse.julialang.org/u/GlenHenshaw)\
**Post date:** [November 26, 2019, 9:45pm UTC](https://discourse.julialang.org/t/cxx-calling-icxx-with-a-string-interpolation-results-in-a-cryptic-boundserror/31508/4 "2019-11-26T21:45:48Z")

</div>

Line 78 of “RMRC.jl” corresponds to the icxx call in the OP.
