When compiling to x86_64 with x32 ABI (the most comfortable way is on Ubuntu 16.04 with the 'libc6-dev-x32' package), I get warnings:
test-times.c: In function ‘main’: test-times.c:64:15: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘clock_t {aka long long int}’ [-Wformat=] printf ("tms.tms_utime %ldms\n", ((long int) tms.tms_utime * 1000) / clk_tck); ^ test-times.c:65:15: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘clock_t {aka long long int}’ [-Wformat=] printf ("tms.tms_stime %ldms\n", ((long int) tms.tms_stime * 1000) / clk_tck); ^ test-times.c:66:15: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘clock_t {aka long long int}’ [-Wformat=] printf ("tms.tms_cutime %ldms\n", ((long int) tms.tms_cutime * 1000) / clk_tck); ^ test-times.c:67:15: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘clock_t {aka long long int}’ [-Wformat=] printf ("tms.tms_cstime %ldms\n", ((long int) tms.tms_cstime * 1000) / clk_tck); ^ test-times.c:98:15: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘clock_t {aka long long int}’ [-Wformat=] printf ("tms.tms_utime %ldms\n", ((long int) tms.tms_utime * 1000) / clk_tck); ^ test-times.c:99:15: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘clock_t {aka long long int}’ [-Wformat=] printf ("tms.tms_stime %ldms\n", ((long int) tms.tms_stime * 1000) / clk_tck); ^ test-times.c:100:15: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘clock_t {aka long long int}’ [-Wformat=] printf ("tms.tms_cutime %ldms\n", ((long int) tms.tms_cutime * 1000) / clk_tck); ^ test-times.c:101:15: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘clock_t {aka long long int}’ [-Wformat=] printf ("tms.tms_cstime %ldms\n", ((long int) tms.tms_cstime * 1000) / clk_tck); ^ This fixes them. 2017-02-12 Bruno Haible <br...@clisp.org> times test: Avoid gcc warnings on Linux/x32. * tests/test-times.c (main): Really cast printf arguments from clock_t to 'long int'. diff --git a/tests/test-times.c b/tests/test-times.c index cfebdf9..4697cd0 100644 --- a/tests/test-times.c +++ b/tests/test-times.c @@ -61,10 +61,10 @@ main (int argc, char *argv[]) printf ("clk_tck %ld\n", (long int) clk_tck); printf ("t %ld\n", (long int) t); - printf ("tms.tms_utime %ldms\n", ((long int) tms.tms_utime * 1000) / clk_tck); - printf ("tms.tms_stime %ldms\n", ((long int) tms.tms_stime * 1000) / clk_tck); - printf ("tms.tms_cutime %ldms\n", ((long int) tms.tms_cutime * 1000) / clk_tck); - printf ("tms.tms_cstime %ldms\n", ((long int) tms.tms_cstime * 1000) / clk_tck); + printf ("tms.tms_utime %ldms\n", ((long int) tms.tms_utime * 1000) / (long int) clk_tck); + printf ("tms.tms_stime %ldms\n", ((long int) tms.tms_stime * 1000) / (long int) clk_tck); + printf ("tms.tms_cutime %ldms\n", ((long int) tms.tms_cutime * 1000) / (long int) clk_tck); + printf ("tms.tms_cstime %ldms\n", ((long int) tms.tms_cstime * 1000) / (long int) clk_tck); } if (argc > 1) @@ -95,10 +95,10 @@ main (int argc, char *argv[]) printf ("clk_tck %ld\n", (long int) clk_tck); printf ("t %ld\n", (long int) t); - printf ("tms.tms_utime %ldms\n", ((long int) tms.tms_utime * 1000) / clk_tck); - printf ("tms.tms_stime %ldms\n", ((long int) tms.tms_stime * 1000) / clk_tck); - printf ("tms.tms_cutime %ldms\n", ((long int) tms.tms_cutime * 1000) / clk_tck); - printf ("tms.tms_cstime %ldms\n", ((long int) tms.tms_cstime * 1000) / clk_tck); + printf ("tms.tms_utime %ldms\n", ((long int) tms.tms_utime * 1000) / (long int) clk_tck); + printf ("tms.tms_stime %ldms\n", ((long int) tms.tms_stime * 1000) / (long int) clk_tck); + printf ("tms.tms_cutime %ldms\n", ((long int) tms.tms_cutime * 1000) / (long int) clk_tck); + printf ("tms.tms_cstime %ldms\n", ((long int) tms.tms_cstime * 1000) / (long int) clk_tck); } return 0;