title: Multiple Errors in .c include file while using union
body: <p>I continuingly fail to find any error in the following (c)code. Yet the compiler is throwing errors on me.</p>
  
  <p>This is the code in </p>
  
  <p>FloatConverter.c</p>
  
  <pre><code>1  #ifndef FloatConverterh
  2  #define FloatConverterh
  3 
  4  #include "FloatConverter.h"
  5  #include &lt;stdint.h&gt;
  6
  7  #define MAXVALUE 6000
  8  union Cast
  9  {
  10    double d;
  11    long l;
  12 };
  13
  14 int32_t float2int( double d )
  15 {
  16     static volatile Cast cast;
  17
  18    cast.d = d + 6755399441055744.0;
  19    return cast.l;
  20 }
  21
  22 // naive
  23 int32_t f32ToInt16Digits( float f32 )
  24 {
  25     return ( ( int32_t )( f32 * 2 * MAXVALUE / 65535 ) ) );
  26 };
  27
  28 // improved
  29 int32_t f32ToInt16Digits2( float f32 )
  30 {
  31    return ( float2int( f32 * 2 * MAXVALUE / 65535 ) );
  32 };
  33
  34 #endif
  </code></pre>
  
  <p>FloatConverter.h</p>
  
  <pre><code>extern int32_t f32ToInt16Digits( float f32 );
  extern int32_t f32ToInt16Digits2( float f32 );
  </code></pre>
  
  <p>I'm sure the error lies within the include file. If I remove it (and all refrences) everything is back to normal and fine.</p>
  
  <p>This are the errors that are put out by the compiler:</p>
  
  <p>In FloatConverter.c</p>
  
  <pre><code>expected '=', ',', ';', 'asm' or '__attribute__' before 'cast' 16
  'cast' undeclared (first use in this function) 16
  expected ';' before ')' token 25
  expected statement before')' token 25
  </code></pre>
  
  <p>in FloatConverter.h:</p>
  
  <pre><code>expected '=', ',', ';', 'asm' or '__attribute__' before 'f32ToInt16Digits' 1
  expected '=', ',', ';', 'asm' or '__attribute__' before 'f32ToInt16Digits2' 2
  </code></pre>
  
  <p>I'm grateful for any hints.</p>