tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

g++7 and _XOPEN_SOURCE (was Re: c++ undefined symbols in lang/openjdk11)



There is actually something very wrong with g++7 header files:
This one-liner:

#include <math.h>

compiles ok with

$ g++ -c -D_XOPEN_SOURCE test.cc  # g++ is native from 8.1

but fails horribly with

$ /usr/pkg/gcc7/bin/g++ -c -D_XOPEN_SOURCE test.cc

with tons of undeclared symbols, even more than the ones I saw at the
start of the thread (FP_NAN, FP_INFINITE, ..., ::double_t, ::float_t...)

Using -D_XOPEN_SOURCE=500 or -D_POSIX_SOURCE doesn't really make it better.
(-D_NETBSD_SOURCE is ok)

This isn't 100% identical to the use case in openjdk11, but it is
similar. (I guess that somewhere behind the scenes it processes
_ALLBSD_SOURCE or _BSDONLY_SOURCE into a problematic official macro)

If you say that one should not use <math.h> in a c++ program:
it fails in exactly the same way with <cmath> (because the two include
each other and similarly named headers in other directories in a
maze-like manner).

-Olaf.
-- 
Olaf 'Rhialto' Seibert -- rhialto at falu dot nl
___  Anyone who is capable of getting themselves made President should on
\X/  no account be allowed to do the job.       --Douglas Adams, "THGTTG"

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index