# Using struct in function

**URL:** <https://forum.legato.io/t/using-struct-in-function/6119>\
**Category:** Uncategorized\
**Created:** [February 23, 2022, 7:12am UTC](https://forum.legato.io/t/using-struct-in-function/6119 "2022-02-23T07:12:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [February 23, 2022, 7:12am UTC](https://forum.legato.io/t/using-struct-in-function/6119/1 "2022-02-23T07:12:47Z")

</div>

I am trying to pass a STRUCT type to a FUNCTION for a legato API, following this topic below but I get a compile error:

> [@In legato 19.02 api is not supporting more than 2 string](https://forum.legato.io/t/in-legato-19-02-api-is-not-supporting-more-than-2-string/5716):
>
> Hi legato, i am facing the issue in legato api struct . please check the below .api\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* STRUCT ARRAY { string Array1[10]; string Array2[10]; string Array3[10]; string Array4[10]; string Array5[10]; }; FUNCTION arraySend ( ARRAY asd ); log\*\*\*\*\*\*\*\* Apr 16 18:23:14 swi-mdm9x28-wp user.info Legato: INFO | canDBC[20710]/canDBCComponent T=canDBC | main.c PeriodicCanDataHdlr() 104 | PeriodicCanDataHdlr Apr 16 18:23:14 swi-mdm9x28-wp user.e…

/offlineData.c:109:6: error: conflicting types for ‘offlineData\_arraySend’  
void offlineData\_arraySend( offlineData\_ARRAY123\_t value)  
^ ~~~~~~~~~~~~~~~~~~~~  
In file included from /…/\_build\_offlineData/wp77xx/component/06e41e7ad659bd0271a38a5c7f355382/src/interfaces.h:16:0,  
from /…/offlineData.c:9:  
/…/\_build\_offlineData/wp77xx/api/a82b406f1aff9e91297c745193364f7e/server/offlineData\_server.h:82:6: note: previous declaration of ‘offlineData\_arraySend’ was here  
void offlineData\_arraySend

so it seems there is a conflict for the data type, I have seen comments about the STRUCT not to be supported, I have previously used the handlers, but I would just like to confirm that these are not supported before doing it for this case as well…

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [February 23, 2022, 7:19am UTC](https://forum.legato.io/t/using-struct-in-function/6119/2 "2022-02-23T07:19:05Z")

</div>

you can see here:

> **[Syntax - Legato Docs](https://docs.legato.io/latest/apiFilesSyntax.html#apiFilesSyntax_typesStruct)**
>
> legato™ is an open source Linux-based embedded platform designed to simplify connected IoT application development

there is STRUCT

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [February 23, 2022, 7:23am UTC](https://forum.legato.io/t/using-struct-in-function/6119/3 "2022-02-23T07:23:47Z")

</div>

this doesn`t mention how to, or if is possible, to pass a struct to a FUNCTION of the API

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [February 23, 2022, 7:27am UTC](https://forum.legato.io/t/using-struct-in-function/6119/4 "2022-02-23T07:27:44Z")

</div>

you can try the sample code here:

> [@In legato 19.02 api is not supporting more than 2 string](https://forum.legato.io/t/in-legato-19-02-api-is-not-supporting-more-than-2-string/5716/2):
>
> how about making the API file like this? STRUCT ARRAY123 { string Array1[10]; int32 port1; string Array2[10]; int32 port2; string Array3[10]; int32 port3; string Array4[10]; int32 port4; string Array5[10]; int32 port5; }; FUNCTION arraySend ( ARRAY123 asd IN ); It is working on my side with vscode leaf swi-wp76\_4.7.0. You can use my code: [IPC\_step1.rar](https://forum.legato.io/uploads/short-url/dgUwkVXIXDa6sS6CbPxzjqn2x7a.rar) (2.4 KB)

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [February 23, 2022, 7:31am UTC](https://forum.legato.io/t/using-struct-in-function/6119/5 "2022-02-23T07:31:07Z")

</div>

as I just mentioned in the first message, this will not compile as it will detect a conflict of definitions.  
please see the initial post I made

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [February 23, 2022, 7:32am UTC](https://forum.legato.io/t/using-struct-in-function/6119/6 "2022-02-23T07:32:03Z")

</div>

did you see problem in swi-wp76\_4.7.0? ( as mentioned in the link)

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [February 23, 2022, 7:34am UTC](https://forum.legato.io/t/using-struct-in-function/6119/7 "2022-02-23T07:34:34Z")

</div>

I am compiling for wp77xx

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [February 23, 2022, 7:43am UTC](https://forum.legato.io/t/using-struct-in-function/6119/8 "2022-02-23T07:43:57Z")

</div>

you can download the swi-wp76\_4.7.0 (legato 20.4.0) easily, this can confirm if issue only happen to your leaf package version or legato version

Or you can try in swi-wp77\_4.2.0 which also uses legato 20.4.0
