title: C11 _Generic c program and errors on Eclipse c/c++
body: <p>Hi  i was studying C for the first time using C primer plus book  then in chapter 16  about _Generic  from C11 standard i wrote a program in Eclipse c/c++ and build  and it produces 8 errors and warning  and i don't know why here is the program and the errors</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  #define RAD_TO_DEG (180/(4 * atanl(1)))
  
  // generic square root function
  #define SQRT(X) _Generic((X),\
      long double: sqrtl, \
      default: sqrt, \
      float: sqrtf)(X)
  
  // generic sine function, angle in degrees
  #define SIN(X) _Generic((X),\
  long double: sinl((X)/RAD_TO_DEG),\
  default:     sin((X)/RAD_TO_DEG),\
  float:       sinf((X)/RAD_TO_DEG)\
  )
  
  int main(void)
  {
      float x = 45.0f;
      double xx = 45.0;
      long double xxx =45.0L;
  
      long double y = SQRT(x);
      long double yy= SQRT(xx);
      long double yyy = SQRT(xxx);
      printf("%.17Lf\n", y);   // matches float
      printf("%.17Lf\n", yy);  // matches default
      printf("%.17Lf\n", yyy); // matches long double
      int i = 45;
      yy = SQRT(i);            // matches default
      printf("%.17Lf\n", yy);
      yyy= SIN(xxx);           // matches long double
      printf("%.17Lf\n", yyy);
  
      return 0;
  }
  </code></pre>
  
  <p>errors </p>
  
  <pre><code>make all 
  Building file: ../generic.c
  Invoking: GCC C Compiler
  gcc -std=c11 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"generic.d" -MT"generic.d" -o "generic.o" "../generic.c"
  ../generic.c: In function ‘main’:
  ../generic.c:24:5: warning: implicit declaration of function ‘_Generic’ [-Wimplicit-function-declaration]
       long double y = SQRT(x);
       ^
  ../generic.c:7:5: error: expected expression before ‘long’
       long double: sqrtl, \
       ^
  ../generic.c:24:21: note: in expansion of macro ‘SQRT’
       long double y = SQRT(x);
                       ^
  ../generic.c:7:5: error: expected expression before ‘long’
       long double: sqrtl, \
       ^
  ../generic.c:25:21: note: in expansion of macro ‘SQRT’
       long double yy= SQRT(xx);
                       ^
  ../generic.c:7:5: error: expected expression before ‘long’
       long double: sqrtl, \
       ^
  ../generic.c:26:23: note: in expansion of macro ‘SQRT’
       long double yyy = SQRT(xxx);
                         ^
  ../generic.c:7:5: error: expected expression before ‘long’
       long double: sqrtl, \
       ^
  ../generic.c:31:10: note: in expansion of macro ‘SQRT’
       yy = SQRT(i);            // matches default
            ^
  ../generic.c:13:1: error: expected expression before ‘long’
   long double: sinl((X)/RAD_TO_DEG),\
   ^
  ../generic.c:33:10: note: in expansion of macro ‘SIN’
       yyy= SIN(xxx);           // matches long double
            ^
  make: *** [generic.o] Error 1
  
  14:47:53 Build Finished (took 66ms)
  </code></pre>
  
  <p>i have used -lm link for math.h and it produces these errors and i don't know why ? </p>