M_PI flagged as undeclared identifier

前端 未结 5 1692
走了就别回头了
走了就别回头了 2020-12-24 05:36

When I compile the code below, I got these error messages:

(Error  1   error C2065: \'M_PI\' : undeclared identifier 
2   IntelliSense: identifier \"M_PI\"          


        
5条回答
  •  囚心锁ツ
    2020-12-24 06:30

    It sounds like you're using MS stuff, according to their docs

    Math Constants are not defined in Standard C/C++. To use them, you must first define _USE_MATH_DEFINES and then include cmath or math.h.

    So you need something like

    #define _USE_MATH_DEFINES
    #include 
    

    as a header.

提交回复
热议问题