GithubHelp home page GithubHelp logo

Comments (6)

bradbell avatar bradbell commented on June 24, 2024

I now have visual studio 2013 up and running without without warnings, expect for the fact that asctime and gmtime are not thread safe (which I have decided to leave for the time being).

Would you please provide a simple example that results in the warnings you intend to fix here and (so I can add it to the CppAD tests to make sure that the fix works).

from cppad.

Loutjie avatar Loutjie commented on June 24, 2024

The warning appear at every call to ‘Forward(0, x)’;

Example:

     std::vector<CppAD::AD<CppAD::zdouble>> vdX(1);

     std::vector<CppAD::AD<CppAD::zdouble>> vdY(1);

     CppAD::ADFun<CppAD::zdouble> Function;

     std::vector<CppAD::zdouble> vdX2(1);

     std::vector<CppAD::zdouble> vdY2(1);

     vdX[0] = 10.0;

     Independent(vdX);

     vdY[0] = vdX[0]*2.0;

     Function.Dependent(vdX, vdY);

     vdX2[0] = 20.0;

     vdY2 = Function.Forward(0, vdX2); // Generates warnings during compilation

If I add this template constructor

template
/// Constructor from double
zdouble(const Base& value)
: dbl_((double)value)
{ }

And remove the double constructor

                /// Constructor from double
     /*zdouble(const double& dbl)
     : dbl_(dbl)
     { }*/

Then the warnings are silenced.

Kind regards

Loutjie

From: Brad Bell [mailto:[email protected]]
Sent: 2015 September 22 07:36 PM
To: coin-or/CppAD
Cc: Loutjie
Subject: Re: [CppAD] Silence warning in Visual Studio 2010 when using zdouble (#10)

I now have visual studio 2013 up and running without without warnings, expect for the fact that asctime and gmtime are not thread safe (which I have decided to leave for the time being).

Would you please provide a simple example that results in the warnings you intend to fix here and (so I can add it to the CppAD tests to make sure that the fix works).


Reply to this email directly or view it on GitHub #10 (comment) . https://github.com/notifications/beacon/AM7EHxXoOUkgr7kYkJdDJIl1MHaHPDNSks5o0YjogaJpZM4FmpYj.gif

from cppad.

Loutjie avatar Loutjie commented on June 24, 2024

We compile at Warning Level 4.

From: Brad Bell [mailto:[email protected]]
Sent: 2015 September 22 07:36 PM
To: coin-or/CppAD
Cc: Loutjie
Subject: Re: [CppAD] Silence warning in Visual Studio 2010 when using zdouble (#10)

I now have visual studio 2013 up and running without without warnings, expect for the fact that asctime and gmtime are not thread safe (which I have decided to leave for the time being).

Would you please provide a simple example that results in the warnings you intend to fix here and (so I can add it to the CppAD tests to make sure that the fix works).


Reply to this email directly or view it on GitHub #10 (comment) . https://github.com/notifications/beacon/AM7EHxXoOUkgr7kYkJdDJIl1MHaHPDNSks5o0YjogaJpZM4FmpYj.gif

from cppad.

bradbell avatar bradbell commented on June 24, 2024

Warning level 4
https://msdn.microsoft.com/en-us/library/thxezb7y.aspx
is the key. It is generating lots more warnings in my tests. I will look
at them.

Brad.

On 9/22/2015 10:15 PM, Loutjie wrote:

We compile at Warning Level 4.

From: Brad Bell [mailto:[email protected]]
Sent: 2015 September 22 07:36 PM
To: coin-or/CppAD
Cc: Loutjie
Subject: Re: [CppAD] Silence warning in Visual Studio 2010 when using
zdouble (#10)

I now have visual studio 2013 up and running without without warnings,
expect for the fact that asctime and gmtime are not thread safe (which
I have decided to leave for the time being).

Would you please provide a simple example that results in the warnings
you intend to fix here and (so I can add it to the CppAD tests to make
sure that the fix works).


Reply to this email directly or view it on GitHub
#10 (comment) .
https://github.com/notifications/beacon/AM7EHxXoOUkgr7kYkJdDJIl1MHaHPDNSks5o0YjogaJpZM4FmpYj.gif


Reply to this email directly or view it on GitHub
#10 (comment).

from cppad.

bradbell avatar bradbell commented on June 24, 2024

On 9/22/2015 10:14 PM, Loutjie wrote:

The warning appear at every call to ‘Forward(0, x)’;

... snip ...

I have made some recent changes and now get no warning (with Visual
Studio 2013) with the following steps in a Windows CMD window
mkdir build
cd build
cmake -G "NMake Makefiles" -D cppad_cxx_flags="/W4" ..
nmake check_example
see
5787b4a

Note that this includes no warnings when compiling the file
https://github.com/coin-or/CppAD/blob/master/example/zdouble.cpp
and that files has order zero forward mode computations (using zdouble)
in it; see the code
z = g.Forward(0, x);
and consider the case where Base = zdouble.

In addition, I have tried replacing zdouble.cpp by the following (at
your suggestion) and still get no warning when executing 'nmake
check_example'.

include <cppad/cppad.hpp>

bool zdouble(void)
{ bool ok = true;
using std::cout;
//
std::vectorCppAD::ADCppAD::zdouble vdX(1);
std::vectorCppAD::ADCppAD::zdouble vdY(1);
CppAD::ADFunCppAD::zdouble Function;
std::vectorCppAD::zdouble vdX2(1);
std::vectorCppAD::zdouble vdY2(1);
vdX[0] = 10.0;
Independent(vdX);
vdY[0] = vdX[0]*2.0;
Function.Dependent(vdX, vdY);
vdX2[0] = 20.0;
vdY2 = Function.Forward(0, vdX2); // Generates warnings during
compilation
//
return ok;
}
~

from cppad.

bradbell avatar bradbell commented on June 24, 2024

If one uses the Visual Studio 2013 and the windows download, extraction, and testing instructions on
http://www.coin-or.org/CppAD/Doc/download.htm#Compressed%20Archives.Windows%20File%20Extraction%20and%20Testing
the only warnings are

  1. C4996: gmtime and asctime my be unsafe.
  2. LNK4044: unrecognized option '/openmp'; ignored
    The functions asctime and gmtime are called when onlly one thread is active and there does not seem to be a standard way to get a thread safe version of these functions. The option /openmp is generated by cmake and is not valid for Visual Studio 2013 (but I think it works for 2015)

Note that the CppAD source code now suppresses the warnings

  1. C4100 unreferenced formal parameter
  2. C4127 conditional expression is constant
    This is mentioned under the heading 09-24 on
    http://www.coin-or.org/CppAD/Doc/whats_new_15.htm#09-24
    CppAD uses the same signature for similar routines that in some cases do not use formal parameters. In addition, it has asserts for expressions that are constant.

from cppad.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.