C11 conformance: <uchar.h>, TIME_UTC, timespec_get

Pavel M pavel.morozkin@gmail.com
Wed Mar 2 23:16:13 GMT 2022


#include <stdio.h>#include <time.h>
int main(void)
{
    struct timespec ts;
    timespec_get(&ts, TIME_UTC);
    char buff[100];
    strftime(buff, sizeof buff, "%D %T", gmtime(&ts.tv_sec));
    printf("Current time: %s.%09ld UTC\n", buff, ts.tv_nsec);
    return 0;
}

$ gcc t667c.c -std=c11 -pedantic -Wall -Wextra
t667c.c: In function ‘main’:
t667c.c:7:5: warning: implicit declaration of function ‘timespec_get’
[-Wimplicit-function-declaration]
    7 |     timespec_get(&ts, TIME_UTC);
      |     ^~~~~~~~~~~~
t667c.c:7:23: error: ‘TIME_UTC’ undeclared (first use in this function)
    7 |     timespec_get(&ts, TIME_UTC);
      |                       ^~~~~~~~
t667c.c:7:23: note: each undeclared identifier is reported only once
for each function it appears in

$ echo "#include <uchar.h>" | gcc -xc - -std=c11 -pedantic -Wall -Wextra
<stdin>:1:10: fatal error: uchar.h: No such file or directory
compilation terminated.

$ gcc --versiongcc (GCC) 11.2.0

$ uname -a
CYGWIN_NT-10.0 xxx 3.3.4(0.341/5/3) 2022-01-31 19:35 x86_64 Cygwin

_NEWLIB_VERSION: 4.1.0
__STDC__: 1 (hm...)


More information about the Newlib mailing list