# WebIDE & Struct?

**URL:** <https://community.particle.io/t/webide-struct/3005>\
**Category:** Cloud\
**Created:** [February 21, 2014, 12:24am UTC](https://community.particle.io/t/webide-struct/3005 "2014-02-21T00:24:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ClintonKeith](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/clintonkeith/32/81_2.png) [@ClintonKeith](https://community.particle.io/u/ClintonKeith)\
**Post date:** [February 21, 2014, 12:24am UTC](https://community.particle.io/t/webide-struct/3005/1 "2014-02-21T00:24:02Z")

</div>

Are structs not working in the WebIDE? I know that with the Arduino IDE, struct definitions have to go into a header, but I can’t do that with the WebIDE:

```
// LIB1.H FILE
struct test{
  unsigned long id;
  char* label;
};

// CPP FILE
// This #include statement was automatically added by the Spark IDE.
#include "lib1.h"

int getEventData(test& e) {
	return 0;
}
void setup() {

}

void loop() {

}

```

Errors encountered:

the\_user\_app.cpp:3:18: error: ‘test’ was not declared in this scope  
the\_user\_app.cpp:3:24: error: ‘e’ was not declared in this scope  
the\_user\_app.cpp: In function ‘int getEventData(test&)’:  
the\_user\_app.cpp:4:25: error: ‘int getEventData(test&)’ redeclared as different kind of symbol  
the\_user\_app.cpp:3:5: error: previous declaration of ‘int getEventData’

---

<div class="post-metadata">

**Author:** ![david\_s5](https://avatars.discourse-cdn.com/v4/letter/d/53a042/32.png) [@david\_s5](https://community.particle.io/u/david_s5)\
**Post date:** [February 21, 2014, 1:03am UTC](https://community.particle.io/t/webide-struct/3005/2 "2014-02-21T01:03:04Z")

</div>

Try using a typedef

```cpp
typedef struct {
  unsigned long id;
  char* label;
} test_t;

int getEventData(test_t & e) {

```

or with what you had…

````cpp
 int getEventData(struct test & e) {```
````

---

<div class="post-metadata">

**Author:** ![ClintonKeith](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/clintonkeith/32/81_2.png) [@ClintonKeith](https://community.particle.io/u/ClintonKeith)\
**Post date:** [February 21, 2014, 3:06am UTC](https://community.particle.io/t/webide-struct/3005/3 "2014-02-21T03:06:11Z")

</div>

Thanks @david_s5 One more: Any idea on how to adapt this:

union genieFrame{  
uint8\_t bytes[GENIE\_FRAME\_SIZE];  
genieFrameReportObj reportObject;  
};

Nothing I seem to try works.

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [February 21, 2014, 4:42am UTC](https://community.particle.io/t/webide-struct/3005/4 "2014-02-21T04:42:59Z")

</div>

Hi @ClintonKeith

Have you seen this thread on the same subject?

> **[Union supported by compiler?](https://community.particle.io/t/union-supported-by-compiler/2714)**
>
> I am working on porting code from arduino to Spark. When I compile, I get errors regarding a variable not being declared in the scope. This variable is clearly defined at the top of the file, after the #defines but uses a “union” of two items. Is...

---

<div class="post-metadata">

**Author:** ![ClintonKeith](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/clintonkeith/32/81_2.png) [@ClintonKeith](https://community.particle.io/u/ClintonKeith)\
**Post date:** [February 21, 2014, 5:22am UTC](https://community.particle.io/t/webide-struct/3005/5 "2014-02-21T05:22:25Z")

</div>

@bko, apparently not but thanks for pointing it out!
