_USE_MATH_DEFINES in C++ (VS2010)
I have got the following problem:
I want to use M_PI
defined in math.h
. I开发者_如何学Pythonn order to do that, one should define _USE_MATH_DEFINES
before including the header.
The following solution works correctly:
#define _USE_MATH_DEFINES
and then
#include < math.h >
However, I would like to add the definition of _USE_MATH_DEFINES
to the Preprocessor Definitions (Project->Properties->C/C++->Preprocessor->Preprocessor Definitions). If I add _USE_MATH_DEFINES
there, M_PI
is not recognized (as without defining the constant at all).
Why is that so? Do you have any ideas?
I do all your steps on my Visual C++ 2010 express and it works for me.
Probably you set macros in debug mode properties and try to compile it in release mode, or set in release mode and try to compile in debug mode. Add macros in release and debug mode properties and try to rebuild (ctrl+alt+F7
) your project.
精彩评论