Code Monkey home page Code Monkey logo

Comments (11)

ahundt avatar ahundt commented on July 29, 2024

this may fix the problem for the moment though it probably isn't the most correct way to do it:

    long sec = static_cast<long>(floor(timeoutSec));
    long usec = static_cast<long>(floor( (timeoutSec - sec) *1e6));
#ifdef __APPLE__

    timeval timeout;
    timeout.tv_sec = sec;
    timeout.tv_usec = usec;
#else
    timeval timeout = { sec, usec };
#endif

Also if you make that change you should consider a very small function rather than the same code in 3 places.

from cisst.

ahundt avatar ahundt commented on July 29, 2024

bump, this issue is still pending

from cisst.

pkazanzides avatar pkazanzides commented on July 29, 2024

Would the following code work?

#if (CISST_OS == CISST_DARWIN)
    time_t sec = static_cast<time_t>(floor(timeoutSec));
    suseconds_t usec = static_cast<suseconds_t>((timeoutSec - sec) * 1e6);
#else
    long sec = static_cast<long>(floor(timeoutSec));
    long usec = static_cast<long>((timeoutSec - sec) * 1e6);
#endif
    timeval timeout = { sec, usec };

I believe the first code block would apply to Linux as well; perhaps to all operating systems except Windows.

from cisst.

ahundt avatar ahundt commented on July 29, 2024

Unfortunately that version wouldn't work because timeval is defined slightly differently on darwin and the bracket notation didn't seem to compile if I recall correctly.

from cisst.

ahundt avatar ahundt commented on July 29, 2024

It could potentially be the following, though I'm not sure how the CISST_DARWIN flag would work on ios:

    long sec = static_cast<long>(floor(timeoutSec));
    long usec = static_cast<long>(floor( (timeoutSec - sec) *1e6));

#if (CISST_OS == CISST_DARWIN)
    timeval timeout;
    timeout.tv_sec = sec;
    timeout.tv_usec = usec;
#else
    timeval timeout = { sec, usec };
#endif

from cisst.

pkazanzides avatar pkazanzides commented on July 29, 2024

The way I read the compiler output, the problem is not with the bracket notation, but rather with the attempt to do an implicit typecast when using the bracket notation. Please try the code I suggested on your Mac -- I don't have one to try it out.

from cisst.

ahundt avatar ahundt commented on July 29, 2024

can we try to move this forward? Resolving these bugs would allow me to use cisst as a library installed on my OS rather than as a directory within my build tree.

from cisst.

pkazanzides avatar pkazanzides commented on July 29, 2024

Try again with the latest checkin (devel branch). Compiled successfully on Windows VS 2008, Ubuntu 12.04 (gcc 4.6.3), and QNX.

from cisst.

ahundt avatar ahundt commented on July 29, 2024

This does not work on OS X, partially because suseconds_t is not a defined type. Furthermore, there are two additional places where the code breaks that were missed by the patch.

The image below shows the lines and changes to the files necessary to work on OS X:
patch for os x

from cisst.

pkazanzides avatar pkazanzides commented on July 29, 2024

If not suseconds_t and time_t, what types does Mac OSX use? If we are going to do conditional compilation for Mac, we might as well use the correct types (I doubt it uses long).

from cisst.

ahundt avatar ahundt commented on July 29, 2024

nevermind, I patched it to work. suseconds_t seems to be ok

from cisst.

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.