samedi 1 octobre 2016

In Keil MDK-ARM C++11 *default NAN value* for member and function's parameter generates strange errors

Have you ever faced with yet another Keil's "feature" when next code

#include <cmath>
struct AB {
  float f=NAN;
  float foo(float a=NAN);
};

generates next build output:

compiling main.cpp...
..\..\src\main.cpp(24): error:  #65: expected a ";"
    float foo(float a=
AN);
..\..\src\main.cpp(24): error:  #109: expression preceding parentheses of apparent call must have (pointer-to-) function type
        float foo(float a=NAN);
..\..\src\main.cpp(24): error:  #18: expected a ")"
        float foo(float a=NAN);
..\..\src\main.cpp(24): error:  #18: expected a ")"
        float foo(float a=NAN);
..\..\src\main.cpp(23): error:  #65: expected a ";"
        float f=NAN;
..\..\src\main.cpp: 0 warnings, 5 errors`

For me it looks like bug. I have never met same nuisance in GCC and other compilers.

Aucun commentaire:

Enregistrer un commentaire