cancel
Showing results for 
Search instead for 
Did you mean: 

Conflicting definitions for PI between TouchGFX and DSP

ERROR
Associate III

Look at this beauty. 

In touchgfx\framework\include\touchgfx\hal\Types.hpp:

static const float PI = 3.14159265358979323846f; ///< PI

In CMSIS-DSP\Include\dsp\fast_math_functions.h

#ifndef PI
  #define PI               3.14159265358979f
#endif

Fortunately, the conflict is caught at compile time.
It’s an exceptionally rare situation when you might need something from TouchGFX (e.g., instrumentation) and CMSIS-DSP at the same time — but when it happens, you get this delightful collision.

Just in case anyone is compiling a list of tricky interview questions.

1 ACCEPTED SOLUTION

Accepted Solutions
LouisB
ST Employee

Hello @ERROR.,

Thanks for your input, unfortunately this can't be fixed and there's no workaround due to backward compatibility. The problem occurs with line like this :

#include <dsp/fast_math_functions.h>
...
touchgfx::PI; // CRASH
...
PI; // OK, but its only and always the DSP's PI
...

We will add this, to the known issues.

BR,

Louis BOUDO
ST Software Engineer | TouchGFX

View solution in original post

1 REPLY 1
LouisB
ST Employee

Hello @ERROR.,

Thanks for your input, unfortunately this can't be fixed and there's no workaround due to backward compatibility. The problem occurs with line like this :

#include <dsp/fast_math_functions.h>
...
touchgfx::PI; // CRASH
...
PI; // OK, but its only and always the DSP's PI
...

We will add this, to the known issues.

BR,

Louis BOUDO
ST Software Engineer | TouchGFX