M_PI flagged as undeclared identifier

前端 未结 5 1719
走了就别回头了
走了就别回头了 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:36

    math.h does not define M_PI by default.

    So go with this:

    #ifndef M_PI
        #define M_PI 3.14159265358979323846
    #endif
    

    This will handle both cases either your header have M_PI defined or not.

提交回复
热议问题