Skip to content

Identifier "M_PI" is undefined #6

Closed

Description

@orijin-tian

Not sure if this issue is important yet, but I figure you may have written it in Linux/macOS as many compilers (especially VS) seem to hide it during build due to it being a 'POSIX extension'. Ends up causing some problems as seen below (The image), then below that I just provided the text from the terminal. The build completed, but those errors were just shown during that process. I simplified the messages and removed my personal parts, but I presume it may be understandable. (I'm not use to writing these issues, so if I did this wrong and you need more info, let me know)

Image

parakeet.cpp\src\fft.cpp(28,29): error C2065: 'M_PI': undeclared identifier \parakeet.cpp\build\parakeet.vcxproj]
mel_gpu.cpp
\parakeet.cpp\src\mel_gpu.cpp(24,33): error C2065: 'M_PI': undeclared identifier \parakeet.cpp\build\parakeet.vcxproj]
\parakeet.cpp\src\mel_gpu.cpp(24,18): error C2737: 'two_pi': const object must be initialized \parakeet.cpp\build\parakeet.vcxproj]

Activity

  1. orijin-tian commented on Jun 2, 2026

    @orijin-tian
    Author

    I was able to fix it with placing #define _USE_MATH_DEFINES before then adding "_USE_MATH_DEFINES" to C/C++: Edit Configurations (JSON) in the command pallet (or just c_cpp_properities.json). Could likely be also fixed with declaring this after cmath:

    #ifndef M_PI
    #define M_PI 3.14159265358979323846
    #endif

  2. mvanhorn commented on Jun 7, 2026

    @mvanhorn
    Contributor

    Opened #18. Defines _USE_MATH_DEFINES before <cmath> (plus an #ifndef M_PI fallback) in fft.cpp/mel_gpu.cpp, and adds _USE_MATH_DEFINES as a PUBLIC MSVC compile definition on the parakeet target so the test executables that also use M_PI build. Non-MSVC builds are unaffected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions