# Julia 1.8.2 message ERROR: LoadError: too many parameters for type

**URL:** <https://discourse.julialang.org/t/julia-1-8-2-message-error-loaderror-too-many-parameters-for-type/91330>\
**Category:** New to Julia\
**Tags:** vector, struct, c\
**Created:** [December 7, 2022, 1:19am UTC](https://discourse.julialang.org/t/julia-1-8-2-message-error-loaderror-too-many-parameters-for-type/91330 "2022-12-07T01:19:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mmv/32/26323_2.png) [@mmv](https://discourse.julialang.org/u/mmv)\
**Post date:** [December 7, 2022, 1:19am UTC](https://discourse.julialang.org/t/julia-1-8-2-message-error-loaderror-too-many-parameters-for-type/91330/1 "2022-12-07T01:19:06Z")

</div>

Hi! The header file (.h) of a C shared library contains the following declaration:

```nohighlight
typedef struct {
  int path; /**< MISR path number */
  long long projcode; /**< GCTP projection code */
  long long zonecode; /**< GCTP zone code */
  long long spherecode; /**< GCTP sphere code */
  double projparam[15]; /**< GCTP projection parameters */
  double ulc[2]; /**< MISR ulc_xy of first block */
  double lrc[2]; /**< MISR lrc_xy of first block */
  int nblock; /**< MISR number blocks */
  int nline; /**< MISR number lines */
  int nsample; /**< MISR number samples */
  float reloffset[179]; /**< MISR relative block offset */
  int resolution; /**< MISR resolution */
} MTKt_MisrProjParam;

```

which I have translated into

```nohighlight
struct MTKt_MisrProjParam
    path::Cint
    projcode::Clonglong
    zonecode::Clonglong
    spherecode::Clonglong
    projparam::Vector{15, Cdouble}
    ulc::Vector{2, Cdouble}
    lrc::Vector{2, Cdouble}
    nblock::Cint
    nline::Cint
    nsample::Cint
    reloffset::Vector{179, Cfloat}
    resolution::Cint
end

```

However, each time I try to use the module containing that declaration, I get the error message

```julia
ERROR: LoadError: too many parameters for type

```

This error comes from anyone of the 4 lines containing `Vector` because commenting them out removes the error. So what should the correct syntax be to include a vector in a struct? Thanks for suggestions.

---

<div class="post-metadata">

**Author:** ![yusri-dh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yusri-dh/32/7404_2.png) [@yusri-dh](https://discourse.julialang.org/u/yusri-dh)\
**Post date:** [December 7, 2022, 2:25am UTC](https://discourse.julialang.org/t/julia-1-8-2-message-error-loaderror-too-many-parameters-for-type/91330/2 "2022-12-07T02:25:48Z")

</div>

Vector only accept one parameter which is the type of the element. So it should be Vector{T}. The struct below can work

```julia
struct MTKt_MisrProjParam
           path::Cint
           projcode::Clonglong
           zonecode::Clonglong
           spherecode::Clonglong
           projparam::Vector{Cdouble}
           ulc::Vector{Cdouble}
           lrc::Vector{Cdouble}
           nblock::Cint
           nline::Cint
           nsample::Cint
           reloffset::Vector{Cfloat}
           resolution::Cint
       end

```

---

<div class="post-metadata">

**Author:** ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)\
**Post date:** [December 7, 2022, 9:03am UTC](https://discourse.julialang.org/t/julia-1-8-2-message-error-loaderror-too-many-parameters-for-type/91330/3 "2022-12-07T09:03:22Z")

</div>

You should use a static vector for this purpose. A `Vector` will only place a pointer in the julia `struct`, whereas the vector itself will be on the heap. Either an `SVector` or an `MVector`:

```julia
using StaticArrays
struct ...
   path::Cint
   ...
   projparam::SVector{15, Cdouble}
   ...
end
```

---

<div class="post-metadata">

**Author:** ![mmv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mmv/32/26323_2.png) [@mmv](https://discourse.julialang.org/u/mmv)\
**Post date:** [December 7, 2022, 9:44am UTC](https://discourse.julialang.org/t/julia-1-8-2-message-error-loaderror-too-many-parameters-for-type/91330/4 "2022-12-07T09:44:41Z")

</div>

@yusri-dh and @sgaure: Thank you both for these valuable inputs. I knew of `Vector` but not `SVector`, so thanks for introducing me to that package.

---

<div class="post-metadata">

**Author:** ![vettert](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vettert/32/30599_2.png) [@vettert](https://discourse.julialang.org/u/vettert)\
**Post date:** [December 8, 2022, 2:47am UTC](https://discourse.julialang.org/t/julia-1-8-2-message-error-loaderror-too-many-parameters-for-type/91330/5 "2022-12-08T02:47:16Z")

</div>

But heed the warnings mentioned in StaticArrays.jl’s readme about vector length. With 179 elements your field reloffset is likely too long for a SVector to be performant.
