user63764: I made this simple code but I'm getting the following error
exit status 1
'RGB' does not name a type

typedef struct
RGB
{
        double r;
        double g;
        double b;
};

RGB led;

RGB func(){
  RGB temp;
  return RGB;
}

I am not getting the error on "RGB led" but just on the function.
Does anyone know a solution for this? Thanks!

user63711: There are 2 errors:
you are returning a class type, and not the temp object
  RGB func(){
    RGB temp;
    return RGB; --> return temp;
  }

To use your typedef you should put the struct "name" after the braced parenthesis:
typedef struct
{
    double r;
    double g;
    double b;
} RGB;


user7508: In plain C, structs are identified by "struc tags", which do not live in
the same namespace as type names. Thus, if you declare
struct RGB {
    ...
};

a variable of this type should be declared as
struct RGB led;

In order to avoid the inconvenience of repeatedly typing struct, a
common idiom is to define it as a type:
typedef struct {
    ...
} RGB;

RGB led;

The Arduino environment, however, is based on the C++ programming
language. In C++ struct tags are types, and you thus do not need the
typedef:
struct RGB {
    ...
};

RGB led;

This is the recommended idiom in C++: just remove the typedef.

63764: <p>I made this simple code but I'm getting the following error</p>

<pre><code>exit status 1
'RGB' does not name a type
</code></pre>

<pre><code>typedef struct
RGB
{
        double r;
        double g;
        double b;
};

RGB led;

RGB func(){
  RGB temp;
  return RGB;
}
</code></pre>

<p>I am not getting the error on "RGB led" but just on the function.
Does anyone know a solution for this? Thanks!</p>
 63711: <p>There are 2 errors:</p>

<p>you are returning a class type, and not the <em>temp</em> object</p>

<pre><code>  RGB func(){
    RGB temp;
    return RGB; --&gt; return temp;
  }
</code></pre>

<p>To use your typedef you should put the struct "name" after the braced parenthesis:</p>

<pre><code>typedef struct
{
    double r;
    double g;
    double b;
} RGB;
</code></pre>
 7508: <p>In plain C, structs are identified by "struc tags", which do not live in
the same namespace as type names. Thus, if you declare</p>

<pre class="lang-cpp prettyprint-override"><code>struct RGB {
    ...
};
</code></pre>

<p>a variable of this type should be declared as</p>

<pre class="lang-cpp prettyprint-override"><code>struct RGB led;
</code></pre>

<p>In order to avoid the inconvenience of repeatedly typing <code>struct</code>, a
common idiom is to define it as a type:</p>

<pre class="lang-cpp prettyprint-override"><code>typedef struct {
    ...
} RGB;

RGB led;
</code></pre>

<p>The Arduino environment, however, is based on the C++ programming
language. In C++ struct tags <em>are</em> types, and you thus do not need the
typedef:</p>

<pre class="lang-cpp prettyprint-override"><code>struct RGB {
    ...
};

RGB led;
</code></pre>

<p>This is the recommended idiom in C++: just remove the typedef.</p>
