This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Do not include the C math.h header before __config
ClosedPublic

Authored by miyuki on Feb 21 2018, 8:08 AM.

Details

Summary

Certain C libraries require configuration macros defined in config
to provide the correct functionality for libc++. This patch ensures
that the C header math.h is always included after the
config
header. It also adds a Windows-specific #if guard for the case when
the C math.h file is included the second time, as suggested by
Marshall in https://reviews.llvm.org/rL323490.

Fixes PR36382.

Diff Detail

Repository
rL LLVM

Event Timeline

miyuki created this revision.Feb 21 2018, 8:08 AM
mclow.lists accepted this revision.Feb 21 2018, 8:38 AM

This LGTM.

This revision is now accepted and ready to land.Feb 21 2018, 8:38 AM
pcc added inline comments.Feb 21 2018, 11:08 AM
include/math.h
1499 ↗(On Diff #135264)

Nit: you don't actually need the && defined(_USE_MATH_DEFINES) part.

mclow.lists added inline comments.Feb 21 2018, 3:24 PM
include/math.h
1499 ↗(On Diff #135264)

I proposed that deliberately.

With the test, if you don't define _USE_MATH_DEFINES and re-include <math.h> it does nothing; which is what you want.

The MS-supplied <math.h> probably does this already, but ...

This revision was automatically updated to reflect the committed changes.