M_PI not available with gcc --std=c11 but with --std=gnu11?

前端 未结 3 1922
悲&欢浪女
悲&欢浪女 2020-12-15 09:55

I noticed M_PI is unavailable on c11. By looking at /usr/include/math.h I can see M_PI is defined if:

#i         


        
3条回答
  •  不思量自难忘°
    2020-12-15 10:12

    The M_PI macro isn't defined by the C11 standard: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf

    Therefore, the #if guards are protecting you from problems in case you want to define your own M_PI macro. gcc is doing exactly the right thing. The standard headers shouldn't arbitrarily define macros that are not in the standard.

提交回复
热议问题