Posted by
SourceForge.net on
Nov 18, 2012; 9:11pm
URL: http://quantlib.414.s1.nabble.com/quantlib-Bugs-3588369-with-fix-vs2010-warning-C4005-M-PI-macro-redefinition-tp13592.html
Bugs item #3588369, was opened at 2012-11-18 13:11
Message generated for change (Tracker Item Submitted) made by marcello-ptr
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112740&aid=3588369&group_id=12740Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Marcello Pietrobon (marcello-ptr)
Assigned to: Nobody/Anonymous (nobody)
Summary: (with fix) vs2010 warning C4005: 'M_PI' : macro redefinition
Initial Comment:
vs2010 with STLPort.5.2.1 and Boost.1_52
XP SP3
I get the annoying warnings:
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\../include/math.h(632): warning C4005: 'M_PI' : macro redefinition
1> D:\Projs\Libraries\Public\QuantLib\QuantLib-Active\ql/mathconstants.hpp(54) : see previous definition of 'M_PI'
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\../include/math.h(639): warning C4005: 'M_SQRT1_2' : macro redefinition
1> D:\Projs\Libraries\Public\QuantLib\QuantLib-Active\ql/mathconstants.hpp(102) : see previous definition of 'M_SQRT1_2'
while compiling ql/utilities/dataparser.cpp
I didn't go to find out if the problem appears without STLPort too,
In syntesis this is what appears as output build with the option 'show includes':
1> Note: including file: D:\Projs\Libraries\Public\QuantLib\QuantLib-Active\ql/utilities/dataparsers.hpp
1> Note: including file: D:\Projs\Libraries\Public\QuantLib\QuantLib-Active\ql/time/date.hpp
1> Note: including file: D:\Projs\Libraries\Public\QuantLib\QuantLib-Active\ql/time/period.hpp
1> Note: including file: D:\Projs\Libraries\Public\QuantLib\QuantLib-Active\ql/time/frequency.hpp
1> Note: including file: D:\Projs\Libraries\Public\QuantLib\QuantLib-Active\ql/qldefines.hpp
1> Note: including file: D:\Projs\Libraries\Bsd\Boost\Boost-Active\boost/config.hpp
1> Note: including file: D:\Projs\Libraries\Bsd\Boost\Boost-Active\boost/config/select_stdlib_config.hpp
1> Note: including file: d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\cstddef
1> Note: including file: d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_prolog.h
1> Note: including file: d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/debug/_debug.h
1> Note: including file: d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_threads.h
1> Note: including file: d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_cstdlib.h
1> Note: including file: d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_cmath.h
1> Note: including file: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\../include/cmath
1> Note: including file: d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\math.h
1> Note: including file: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\../include/math.h
// ** defined here **
1> Note: including file: D:\Projs\Libraries\Public\QuantLib\QuantLib-Active\ql/utilities/null.hpp
1> Note: including file: D:\Projs\Libraries\Public\QuantLib\QuantLib-Active\ql/time/period.hpp
1> Note: including file: D:\Projs\Libraries\Public\QuantLib\QuantLib-Active\ql/errors.hpp
1> Note: including file: D:\Projs\Libraries\Bsd\Boost\Boost-Active\boost/lexical_cast.hpp
...
1> Note: including file: D:\Projs\Libraries\Bsd\Boost\Boost-Active\boost/math/special_functions/sign.hpp
...
1> Note: including file: D:\Projs\Libraries\Bsd\Boost\Boost-Active\boost/math/special_functions/math_fwd.hpp
...
1> Note: including file: D:\Projs\Libraries\Bsd\Boost\Boost-Active\boost/math/policies/policy.hpp
...
1> Note: including file: d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\math.h
1> Note: including file: d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_cprolog.h
1> Note: including file: d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/config/_prolog.h
1> Note: including file: d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/config/_warnings_off.h
1> Note: including file: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\../include/math.h
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\../include/math.h(643): warning C4005: 'M_SQRT1_2' : macro redefinition
1> D:\Projs\Libraries\Public\QuantLib\QuantLib-Active\ql/mathconstants.hpp(103) : see previous definition of 'M_SQRT1_2'
Analysis:
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\../include/math.h
is included twice, but the first time M_PI doesnt get defined
then D:\Projs\Libraries\Public\QuantLib\QuantLib-Active\ql\mathconstants.hpp is included
and then again (the 2nd time)
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\../include/math.h
but this time with the macro _USE_MATH_DEFINES defined (see note in math.h)
and here we get the warning message.
Solution:
In ql\utilities\dataparsers.cpp
before
#include <ql/utilities/dataparsers.hpp>
add the following lines:
#ifdef _MSC_VER // MP-
# define _USE_MATH_DEFINES
//# include <math.h> // not necessary
#endif // MP-
To #include <math.h> is not necessary because dataparsers.hpp indirectly already includes it
before ql\mathconstants.hpp gets included.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112740&aid=3588369&group_id=12740------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev