https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117210

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Dimitry Andric from comment #10)
> Yes, that works. So maybe we were lucky that cdefs.h got transitively
> included in the past, but not anymore?

No. <cmath> basically does this:

#include <bits/c++config.h> // which includes:
#include <bits/os_defines.h>  // which defines:
#define _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC (_GLIBCXX_USE_C99_DYNAMIC ||
!defined __LONG_LONG_SUPPORTED)
# include <math.h> // which includes
#include <sys/cdefs.h> // which defines
#define __LONG_LONG_SUPPORTED
// ...
#if ! _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC


As I said in comment 7, the old definition of the DYNAMIC macro meant it did
not care about the value of __LONG_LONG_SUPPORTED until the DYNAMIC macro was
used, which was after <sys/cdefs.h>. So __LONG_LONG_SUPPORTED was defined then.

The new definition of the DYNAMIC macro expands the value of
__LONG_LONG_SUPPORTED immediately, before cdefs.h has been defined.


> That said, sys/cdefs.h is really a bit of a FreeBSD implementation detail.

Which is why it should be included in the bsd/freebsd/os_defines.h file, not
elsewhere.

> It does get included automatically with most of the regular system headers,
> including <stdlib.h>.

But those aren't included until after <bits/c++config.h> which includes
os_defines.h

Reply via email to