hi all, apologies if this problem is due to something i have not set
the clock() function records time correctly when used in a 64bit console app but not when used in a 32bit console app.
i tried adding -GX to CFLAGS but option is unknown in 32bit mode
i am using Pelles C for windows, ver. 13.00.0 release candidate 2
some test code follows
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
void waitabit(int);
void delay(int);
int main()
{
printf("testing clock() calls ...\n");
waitabit(5);
waitabit(10);
waitabit(15);
waitabit(20);
waitabit(25);
exit(0);
}
void waitabit(int s)
{
clock_t start,end;
double msec;
double sec;
printf("wait level %d between clock calls\n",s);
start = clock();
delay(s);
end = clock();
msec = (double)(end - start) * 1000L / CLOCKS_PER_SEC;
sec = (double)(end - start) / CLOCKS_PER_SEC;
printf("clock() start %ld end: %ld time: %f msec %f sec\n",start,end,msec,sec);
}
void delay(int s)
{
int i,j;
int d = 1000 * s;
clock_t t;
printf("start..");
for(i=0; i<d; i++)
{
for (j=0; j<10000; j++)
t = clock();
}
printf("end\n");
}
I haven't tested, but...
does your computer have a large uptime? The GetTickCount (32-bit) function overflows after about 47 days of machine uptime, and that may be causing the behavior.
hi thanks for your suggestion but no large uptime - shuts down at least once a day
also console app works fine when 64bit build but not as 32bit
also was working as 32bit on pelles c v12
Quote from: nub on May 01, 2025, 03:40:07 AMalso was working as 32bit on pelles c v12
Confirmed.
Windows 11 24H2
Pelles C 12.00.2
Setting 32-bit environment for Pelles C...
Compiling "E:\T\wait.c" with Pelles C pocc.exe
E:\T\wait.c(27): warning #1039: [ISO] No newline at end of file.
E:\T\wait.c(8): warning #2117: Old-style function definition for 'main'.
Linking ................
Finished!
PS E:\T> .\wait
wait 1 seconds between clock calls
clock() = 0 0 msec 0 sec
clock() = 1013 1013000 msec 1013 sec
wait 2 seconds between clock calls
clock() = 1013 1013000 msec 1013 sec
clock() = 3020 3020000 msec 3020 sec
wait 3 seconds between clock calls
clock() = 3021 3021000 msec 3021 sec
clock() = 6035 6035000 msec 6035 sec
wait 1 seconds between clock calls
clock() = 6036 6036000 msec 6036 sec
clock() = 7038 7038000 msec 7038 sec
wait 1 seconds between clock calls
clock() = 7039 7039000 msec 7039 sec
clock() = 8043 8043000 msec 8043 sec
PS E:\T> pc64 wait
E:\T>setlocal
Setting 64-bit environment for Pelles C...
Compiling "E:\T\wait.c" with Pelles C pocc.exe
E:\T\wait.c(27): warning #1039: [ISO] No newline at end of file.
E:\T\wait.c(8): warning #2117: Old-style function definition for 'main'.
Linking ................
Finished!
PS E:\T> .\wait
wait 1 seconds between clock calls
clock() = 0 0 msec 0 sec
clock() = 1013 1013000 msec 1013 sec
wait 2 seconds between clock calls
clock() = 1013 1013000 msec 1013 sec
clock() = 3019 3019000 msec 3019 sec
wait 3 seconds between clock calls
clock() = 3019 3019000 msec 3019 sec
clock() = 6028 6028000 msec 6028 sec
wait 1 seconds between clock calls
clock() = 6029 6029000 msec 6029 sec
clock() = 7032 7032000 msec 7032 sec
wait 1 seconds between clock calls
clock() = 7032 7032000 msec 7032 sec
clock() = 8036 8036000 msec 8036 sec
the test code in the original post has been updated.
I was incorrectly using sleep() to delay between clock() calls, amongst other mistakes.
Problem with a missing check of first argument to X86 runtime helpers for long long multiply, signed/unsigned divide, and signed/unsigned modulo in leaf functions. Should be fixed now.
Wow Pelle, you're a wizard. Looking forward to the next release :D
thanks for the quick action pelle.
where can we access latest as the website holds 2nd April version ?