Having trouble with clock function

S

Stu

Hi guys,

I've been having trouble getting the clock function to work portably,
please could I get some thoughts?

<Possibly OT comments>
It works fine on my laptop (under WinXP) and on my office computer
(under Linux), but I have to write some code for the system simulator
for the Cell BE processor (the thing inside the PS3), which is
apparently a PPC architecture, and I can't get the clock function to
return anything sensible - it returns 0 every time for no apparent
reason.
</Possibly OT comments>

The following is a cut-down version of my code which exhibits the
problem I'm having :) Any thoughts please? As far as I know the clock
function specification says something like "give the best result you
can", but surely "return 0;" wasn't what was in mind...?

#include <iostream>
#include <time.h>

int main()
{
for(;;) // (this is just example code)
{
std::cout << clock() << std::endl;
}

return 0;
}

Cheers,
Stu
 
L

Lionel B

Hi guys,

I've been having trouble getting the clock function to work portably,
please could I get some thoughts?

<Possibly OT comments>
It works fine on my laptop (under WinXP) and on my office computer
(under Linux), but I have to write some code for the system simulator
for the Cell BE processor (the thing inside the PS3), which is
apparently a PPC architecture, and I can't get the clock function to
return anything sensible - it returns 0 every time for no apparent
reason.
</Possibly OT comments>

The following is a cut-down version of my code which exhibits the
problem I'm having :) Any thoughts please? As far as I know the clock
function specification says something like "give the best result you
can", but surely "return 0;" wasn't what was in mind...?

Maybe not... OTOH it doesn't violate the standard. You'd probably be best
off asking on a forum for your platform.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top