How can I use c11 headers in openbsd?

195 Views Asked by At

I want to use specific c11 macros in my C code, but they aren't available. I installed gcc 8.4 via pkg_add on a fresh OpenBSD 7.1 install. /usr/include/float.h is missing any c11 definitions.

gcc-8.4:

sunfire$ egcc -std=c11 prog.c
prog.c: In function 'main':
prog.c:5:17: error: 'FLT_DECIMAL_DIG' undeclared (first use in this function); did you mean 'DECIMAL_DIG'?
printf("%d\n", FLT_DECIMAL_DIG);
               ^~~~~~~~~~~~~~~
               DECIMAL_DIG

clang-13.0.0:

sunfire$ clang prog.c -std=c11                                                       
prog.c:5:18: error: use of undeclared identifier 'FLT_DECIMAL_DIG'
        printf("%d \n", FLT_DECIMAL_DIG);
                        ^
1 error generated.

I looked into the FreeBSD headers and they ship with c11 definitions. Is there a reason OpenBSD does not include those definitions?

Update: Code to reproduce:

#include <stdio.h>
#include <float.h>

int main() {
        printf("%d \n", FLT_DECIMAL_DIG);
}

Output on GNU/Linux x86-64 is 9\n

0

There are 0 best solutions below