#78 x64 compilation for Visual Studio, remove warnings

None
closed-accepted
None
5
2013-07-30
2013-05-06
No

This patch removes most of the Windows x64 compilation warnings, although the majority is just disabled (only for Windows x64!) until we find a better solution. Additionally some math macro redefinition warnings are removed.

Win32 and x64 tests still run without reporting a problem.

There is still a warning (when compiling x64) in marketmodel.cpp, marketmodel_smm.cpp, marketmodel_cms.cpp, marketmodel_smmcaplethomocalibration.cpp, marketmodel_smmcapletcalibration.cpp, marketmodel_smmcapletalphacalibration.cpp each. It is about an implicit conversion from __int64 to QuantLib::Real in a std::copy operation, which can be avoided using a transform. Since I am not sure whether everybody will like that I will suggest an additional patch for those.

1 Attachments

Discussion

  • Luigi Ballabio

    Luigi Ballabio - 2013-05-16

    Thanks, I've committed most of your changes to the trunk, except for two I wasn't sure about.

    The macro redefinition warnings should have been already fixed on the trunk. Do you still get the warning? What is the text?

    Also, I wasn't sure what was the problem with the Size variable in ql/pricingengines/vanilla/analytich1hwengine.cpp. What was the warning in this case?

     
    Last edit: Luigi Ballabio 2013-05-16
  • Luigi Ballabio

    Luigi Ballabio - 2013-05-16
    • assigned_to: Luigi Ballabio
    • Group: -->
     
    • Johannes Göttker-Schnetmann

      Compiling the trunk in x64 as of this morning I get the following warnings:
      1>ql\pricingengines\vanilla\analytich1hwengine.cpp(93): warning C4244: 'argument' : conversion from 'QuantLib::Size' to 'QuantLib::Real', possible loss of data

      I guess that's because 64 bit is more than the 52 bit double mantissa.

      1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(632): warning C4005: 'M_PI' : macro redefinition
      1> C:\Development\QuantLib\trunk\QuantLib\ql/mathconstants.hpp(54) : see previous definition of 'M_PI'
      1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(639): warning C4005: 'M_SQRT1_2' : macro redefinition
      1> C:\Development\QuantLib\trunk\QuantLib\ql/mathconstants.hpp(102) : see previous definition of 'M_SQRT1_2'
      1> smilesectionutils.cpp
      1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(632): warning C4005: 'M_PI' : macro redefinition
      1> C:\Development\QuantLib\trunk\QuantLib\ql/mathconstants.hpp(54) : see previous definition of 'M_PI'
      1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(639): warning C4005: 'M_SQRT1_2' : macro redefinition
      1> C:\Development\QuantLib\trunk\QuantLib\ql/mathconstants.hpp(102) : see previous definition of 'M_SQRT1_2'

      15> garch.cpp
      15>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(632): warning C4005: 'M_PI' : macro redefinition
      15> C:\Development\QuantLib\trunk\QuantLib\ql/mathconstants.hpp(54) : see previous definition of 'M_PI'
      15>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(639): warning C4005: 'M_SQRT1_2' : macro redefinition
      15> C:\Development\QuantLib\trunk\QuantLib\ql/mathconstants.hpp(102) : see previous definition of 'M_SQRT1_2'

      15> mersennetwister.cpp
      15>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(632): warning C4005: 'M_PI' : macro redefinition
      15> C:\Development\QuantLib\trunk\QuantLib\ql/mathconstants.hpp(54) : see previous definition of 'M_PI'
      15>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(639): warning C4005: 'M_SQRT1_2' : macro redefinition
      15> C:\Development\QuantLib\trunk\QuantLib\ql/mathconstants.hpp(102) : see previous definition of 'M_SQRT1_2'

      In my Visual Studio 2010 installation the relevant section in math.h starts with
      #if defined(_USE_MATH_DEFINES) && !defined(_MATH_DEFINES_DEFINED)
      #define _MATH_DEFINES_DEFINED

      Therefore for this installation either _USE_MATH_DEFINES needs to be undefined or _MATH_DEFINES_DEFINED needs to be defined to avoid double defines.

      Kind regards,
      Johannes

       
      Last edit: Johannes Göttker-Schnetmann 2013-05-17
  • Luigi Ballabio

    Luigi Ballabio - 2013-05-20

    What happens if you leave

    #define _USE_MATH_DEFINES
    

    in ql/qldefines.hpp, but add

    #undef _USE_MATH_DEFINES
    

    at the end of ql/mathconstants.hpp? This should still try to get the <math.h> defines, but should avoid the warnings and be a little more robust against different order of inclusion of the standard and QuantLib headers in client code. However, my brain still hurts from trying to figure out the inclusions, so I might be wrong.

     
  • Johannes Göttker-Schnetmann

    Inclusions can be a nightmare. :)

    But your suggestion removes all the double define warnings, only the first warning

    1>ql\pricingengines\vanilla\analytich1hwengine.cpp(93): warning C4244: 'argument' : conversion from 'QuantLib::Size' to 'QuantLib::Real', possible loss of data

    is still there.

     
    Last edit: Johannes Göttker-Schnetmann 2013-05-21
  • Luigi Ballabio

    Luigi Ballabio - 2013-05-21

    Both warnings should be gone now. Let me know if there still are problems.

     
  • Johannes Göttker-Schnetmann

    Unfortunately there are still two. The difference was that I had put the #undef right at the end (after the last #endif).

    1> smilesectionutils.cpp
    1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(632): warning C4005: 'M_PI' : macro redefinition
    1> C:\Development\QuantLib\trunk\QuantLib\ql/mathconstants.hpp(54) : see previous definition of 'M_PI'
    1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(639): warning C4005: 'M_SQRT1_2' : macro redefinition
    1> C:\Development\QuantLib\trunk\QuantLib\ql/mathconstants.hpp(102) : see previous definition of 'M_SQRT1_2'

     
  • Luigi Ballabio

    Luigi Ballabio - 2013-07-30
    • status: open --> closed-accepted
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks