public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>,
Andrea Monaco via Glibc-bugs <glibc-bugs@sourceware.org>
Cc: Andrea Monaco <andrea.monaco@autistici.org>
Subject: Re: CLK_TCK undefined
Date: Wed, 18 Oct 2023 09:45:58 -0300 [thread overview]
Message-ID: <1a9387e4-8b7e-4b59-b457-01324305cdf6@linaro.org> (raw)
In-Reply-To: <87bkcwgsql.fsf@oldenburg.str.redhat.com>
On 18/10/23 06:55, Florian Weimer via Glibc-bugs wrote:
> * Andrea Monaco via Glibc-bugs:
>
>> The constant CLK_TCK seems not defined in my glibc headers, although
>> it's required by C89 (according to the draft I'm using). Is that
>> intended?
>
> We have a conditional definition in <time.h>:
>
> #if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \
> && !defined __USE_XOPEN2K
> /* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK
> presents the real value for clock ticks per second for the system. */
> extern long int __sysconf (int);
> # define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
> #endif
>
> Maybe your choice of feature selection macros suppresses the definition?
It was removed by POSIX 2001 [1]:
Issue 6
The symbolic name CLK_TCK is removed. Application usage is added describing
how its equivalent functionality can be obtained using sysconf().
You need to specify an old POSIX version to actually use it:
$ cat t.c
#include <time.h>
#include <stdio.h>
#include <stdint.h>
int main (int argc, char *argv[])
{
printf ("%jd\n", (intmax_t) CLK_TCK);
return 0;
}
$ gcc -Wall t.c -o t -D_POSIX_C_SOURCE=200112L
t.c: In function ‘main’:
t.c:7:31: error: ‘CLK_TCK’ undeclared (first use in this function)
7 | printf ("%jd\n", (intmax_t) CLK_TCK);
| ^~~~~~~
t.c:7:31: note: each undeclared identifier is reported only once for each function it appears in
$ gcc -Wall t.c -o t -D_POSIX_C_SOURCE=199506
$ ./t
100
[1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html
next prev parent reply other threads:[~2023-10-18 12:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 13:15 Andrea Monaco
2023-10-18 9:55 ` Florian Weimer
2023-10-18 12:45 ` Adhemerval Zanella Netto [this message]
2023-10-19 7:00 ` Andrea Monaco
2023-10-19 7:55 ` Andreas Schwab
2023-10-19 9:42 ` Andrea Monaco
2023-10-19 18:02 ` Joseph Myers
2023-10-18 11:19 ` Andreas Schwab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1a9387e4-8b7e-4b59-b457-01324305cdf6@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=andrea.monaco@autistici.org \
--cc=fweimer@redhat.com \
--cc=glibc-bugs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).