# Error: '...' does not name a type

**URL:** <https://forum.arduino.cc/t/error-does-not-name-a-type/564582>\
**Category:** Programming\
**Created:** [December 29, 2018, 3:41pm UTC](https://forum.arduino.cc/t/error-does-not-name-a-type/564582 "2018-12-29T15:41:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alvin\_shek\_99](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@alvin\_shek\_99](https://forum.arduino.cc/u/alvin_shek_99)\
**Post date:** [December 29, 2018, 3:41pm UTC](https://forum.arduino.cc/t/error-does-not-name-a-type/564582/1 "2018-12-29T15:41:42Z")

</div>

Hi all,

This is my first forum post ever, so please let me know if I have not followed standard post procedures. I am trying to define a struct in a separate header file, "test\_header.h" and then create an instance of this in my main file, "test.ino". The code does nothing, but highlights my problem.

For some reason, I get the compilation error: "arm0 does not name a type". I am confused since arm0 clearly has been declared right before as a "struct store\_arm\_data\_struct".

Thank you for your help!

[test\_header.h](https://forum.arduino.cc/uploads/short-url/yNFni3hjsCOBRDNDvdsXlLtz3nO.h) (183 Bytes)

[test.ino](https://forum.arduino.cc/uploads/short-url/8PuaLaQSI4PwoOuxb9DiF9uauxK.ino) (194 Bytes)

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [December 29, 2018, 4:04pm UTC](https://forum.arduino.cc/t/error-does-not-name-a-type/564582/2 "2018-12-29T16:04:32Z")

</div>

> This is my first forum post ever, so please let me know if I have not followed standard post procedures.

Welcome to the forum

Please post your code here rather than attaching it as it is so small. When you post it please use code tags. Don't know what they are ? then [read this before posting a programming question](http://forum.arduino.cc/index.php?topic=97455.0)

If you make it easier to copy your code to an editor for examination you are likely to get a faster and more complete reply

---

<div class="post-metadata">

**Author:** ![bperrybap](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bperrybap/32/605367_2.png) [@bperrybap](https://forum.arduino.cc/u/bperrybap)\
**Post date:** [December 29, 2018, 5:12pm UTC](https://forum.arduino.cc/t/error-does-not-name-a-type/564582/3 "2018-12-29T17:12:56Z")

</div>

[https://en.cppreference.com/w/c/language/struct\_initialization](https://en.cppreference.com/w/c/language/struct_initialization)

---

<div class="post-metadata">

**Author:** ![alvin\_shek\_99](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@alvin\_shek\_99](https://forum.arduino.cc/u/alvin_shek_99)\
**Post date:** [December 29, 2018, 11:53pm UTC](https://forum.arduino.cc/t/error-does-not-name-a-type/564582/4 "2018-12-29T23:53:17Z")

</div>

Hi UKHeliBob,

Thanks for letting me know. For everyone's convenience, here is my test code so you don't have to download those files:

test.ino:

```cpp
#include "test_header.h"

struct store_arm_data_struct arm0;
arm0.motor0_step_pin = 2;
arm0.motor1_step_pin = 3;
arm0.motor0_dir_pin = 4;
arm0.motor1_dir_pin = 5;

```

test\_header.h:

```cpp
#ifndef _ARM_DATA_H_
#define _ARM_DATA_H_

struct store_arm_data_struct {
    int motor0_step_pin;
    int motor1_step_pin;
    int motor0_dir_pin;
    int motor1_dir_pin;
};

#endif

```

Hi bperrybap,  
Thank you for sending this reference. I am sure that I have followed the correct struct initialization procedure for c++. God I just realized that since this is Arduino, you need to modify variables inside the void loop() or void setup() functions instead of outside... Thanks for the help everyone.

---

<div class="post-metadata">

**Author:** ![bperrybap](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bperrybap/32/605367_2.png) [@bperrybap](https://forum.arduino.cc/u/bperrybap)\
**Post date:** [December 30, 2018, 12:46am UTC](https://forum.arduino.cc/t/error-does-not-name-a-type/564582/5 "2018-12-30T00:46:40Z")

</div>

> alvin\_shek\_99:  
> I am sure that I have followed the correct struct initialization procedure for c++.

```arduino
#include "test_header.h"

struct store_arm_data_struct arm0 = {
 .motor0_step_pin = 2, 
 .motor1_step_pin = 3,
 .motor0_dir_pin = 4,
 .motor1_dir_pin = 5
};

void setup(){}

void loop(){}

```

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 11:32pm UTC](https://forum.arduino.cc/t/error-does-not-name-a-type/564582/6 "2021-05-05T23:32:56Z")

</div>

Closed on May 5, 2021, 11:32pm UTC


