c++visual-studio-2010cmath

M_PI in VS2010: working in Debug conf but not in Release


In my unmanaged C++ source i have:

#define _USE_MATH_DEFINES
#include <cmath>

and then I use M_PI a couple of times. Compiling in Debug configuration works flawlessly but in Release it gives:

error C2065: 'M_PI' : undeclared identifier

What could be the configuration property causing this?


Solution

  • Solved.

    I had put

    #define _USE_MATH_DEFINES
    

    before

    #include "stdafx.h"
    

    With Precompiled Headers on (/Yu), as it's in Release mode, everything above it is ignored.