Where is `M_PI` defined?

My VSC has a red squiggle under M_PI, it’s not an issue because it builds fine, BUT I really hate red squiggles, anyone know where its definition is?

image

I did search the Rack-SDK source, but can’t find it there

1 Like

Ah right, I thought it was a Rack definition.

I’ve tried adding math.h and cmath includes and I also see FLAGS += -D_USE_MATH_DEFINES in the Makefile, so I tried that too, but so far this hasn’t resolved the red squiggle :rage:

I’ll keep trying…

It’s included in <cmath> as a POSIX extension.

1 Like

Ah ha, got it, thanks for the pointers.

Have to add this to any file I want to understand the M_PI

#define _USE_MATH_DEFINES
#include <cmath>

then:

image

You might have to surround the include via an #ifdef#endif specific to a VSC flag, as gcc might baulk at such an include request.

My local machine is Windows10 using Msys2, so I build using g++ v10.2.0 and it seems fine with it

It might work linux - "cmath: No such file or directory" when compiled with GCC - Stack Overflow … depends on the Makefile.

:partying_face: Working on my knobs

3 Likes