# Typedef und structs

**URL:** <https://forum.arduino.cc/t/typedef-und-structs/1228622>\
**Category:** Deutsch\
**Created:** [February 26, 2024, 8:29am UTC](https://forum.arduino.cc/t/typedef-und-structs/1228622 "2024-02-26T08:29:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![makkustm](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@makkustm](https://forum.arduino.cc/u/makkustm)\
**Post date:** [February 26, 2024, 8:29am UTC](https://forum.arduino.cc/t/typedef-und-structs/1228622/1 "2024-02-26T08:29:22Z")

</div>

Guten Tag zusammen,

wo genau liegt der Unterschied zwischen struct und typedef struct?

Bsp.:

```arduino
typedef struct { 
byte age;
string name;
 } Person;

Person person;

```

```arduino
struct Person {
byte age;
string name;
};
Person person;

```

Im Internet stoße ich nur immer auf das Argument, dass bei der Verwendung ohne "typedef" "struct" verwendet werden muss, bei der Erstellung einer neuen Instanz -\> struct Person person;  
was ich bisher aber so nie nutzen musste.

LG

---

<div class="post-metadata">

**Author:** ![michael\_x](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/michael_x/32/628623_2.png) [@michael\_x](https://forum.arduino.cc/u/michael_x)\
**Post date:** [February 26, 2024, 8:37am UTC](https://forum.arduino.cc/t/typedef-und-structs/1228622/2 "2024-02-26T08:37:19Z")

</div>

Google meint, [dies](https://www.tutorialspoint.com/difference-between-struct-and-typedef-struct-in-cplusplus-program#:~:text=Basically%20struct%20is%20used%20to,without%20writing%20the%20struct%20keyword.) sei die beste Antwort:

(In C++ gibts keinen Unterschied, _außer bei einer Vorwärtsdeklaration_.)

---

<div class="post-metadata">

**Author:** ![combie](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/combie/32/217369_2.png) [@combie](https://forum.arduino.cc/u/combie)\
**Post date:** [February 26, 2024, 12:26pm UTC](https://forum.arduino.cc/t/typedef-und-structs/1228622/3 "2024-02-26T12:26:42Z")

</div>

> [@makkustm](#):
>
> wo genau liegt der Unterschied zwischen struct und typedef struct?

Die erste Variante ist C  
Die zweite ist C++

Die erste wird auch von C++ verstanden.

Die Verwendung von typedef ist (soweit mir bekannt) in C++ nicht mehr nötig.  
Aus historischen Gründen bzw. Nostalgie mag es noch Vorkommen geben.  
Auch in der libstdc++ findet es sich noch.

Bemerke:  
Arduino ist C++ !  
Ins besondere die \*.ino und \*.cpp Dateien sowie fast alle Libraries

---

<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:** [August 24, 2024, 12:27pm UTC](https://forum.arduino.cc/t/typedef-und-structs/1228622/4 "2024-08-24T12:27:11Z")

</div>

Closed on August 24, 2024, 12:27pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
