Request or comment: 8071690: Include local HotSpot headers before the system headers

Kim Barrett kim.barrett at oracle.com
Sat Jan 31 01:53:51 UTC 2015


On Jan 28, 2015, at 5:50 AM, David Holmes <david.holmes at oracle.com> wrote:
> 
> I thought the double underscore macros were only for compiler use - so what normally sets it and what does it get used for?

__STDC_FORMAT_MACROS, __STDC_CONSTANT_MACROS, and __STDC_LIMIT_MACROS
are "user-level" configuration macros for <inttypes.h> and <stdint.h>
that are suggested by the C99 standard. [Note that I say "suggested"
because they are only ever mentioned in footnotes, which are
non-normative.]

They are supposed to control whether those headers define certain sets
of macros when those headers are processed by a C++
implementation. [One might wonder what business a C standard has in
saying anything at all about what C++ implementations should do.]  So
they are explicitly intended to be defined by application code.

I've seen problems with dealing with these in other code bases.  I've
only seen two methods for dealing with them that seemed to work
reliably:

- Forbid the use of the affected macros in headers.  In translation
  units that want to use the affected macros, define the associated
  enabling macro at the top, prior to any includes.

- Globally define the desired enabling macros via the build system.



More information about the hotspot-dev mailing list