This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: hypot define in pyconfig.h clashes with g++'s cmath
Type: compile error Stage: resolved
Components: Windows Versions: Python 3.8, Python 3.7, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brian.curtin, eudoxos, jdemeyer, loewis, mark.dickinson, methane, miss-islington, miss-islington, pas, pokulo, schmir, steve.dower, terry.reedy, thewtex
Priority: normal Keywords:

Created on 2011-03-15 23:39 by schmir, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 880 merged thewtex, 2017-03-28 19:48
PR 11283 merged thewtex, 2018-12-24 14:00
PR 11284 merged miss-islington, 2018-12-24 14:07
Messages (40)
msg131067 - (view) Author: Ralf Schmitt (schmir) Date: 2011-03-15 23:39
The following program

#include <Python.h>
#include <cmath>

results in the following error when compiled with g++ and -std=gnu++0x:

$ g++ -std=gnu++0x -c t.cc -I /c/Python27/Include
In file included from c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.5.1/include/c++/cmath:629:0,
                 from t.cc:2:
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.5.1/include/c++/tr1_impl/cmath:203:11: error: '::hypot' has not been declared

The problem is, that pyconfig.h has the following define:

#define hypot _hypot

It should probably just be removed when using gcc.
msg172674 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2012-10-11 18:59
Cannot reproduce, and cannot find the define in pyconfig.h. It's in PC/pyconfig.h, but shouldn't affect compiling with gcc.
msg172675 - (view) Author: Ralf Schmitt (schmir) Date: 2012-10-11 19:02
Sorry, if I haven't been clear enough. This happens on windows when compiling extensions with "g++ -std=gnu++0x ..."
msg172683 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2012-10-11 19:44
On MinGW? I'm not a Windows user, but IIRC building extensions with gcc on MinGW has many problems and isn't officially supported.
msg172684 - (view) Author: Ralf Schmitt (schmir) Date: 2012-10-11 19:52
yes, mingw. it may have some problems and this is one of them!
msg174157 - (view) Author: Václav Šmilauer (eudoxos) * Date: 2012-10-29 22:45
I would like to second Ralf here. I am having the same issue with mingw's gcc 4.7 and -std=c++11.
msg174197 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-10-30 10:16
I think there's something generally smelly about the way hypot is handled;  this isn't the only hypot-related build issue that's turned up.  I'm wondering whether the code can be reworked to deal with hypot in the same way that functions like log1p, etc. are dealt with in the math module---i.e., define a _Py_hypot wrapper function, and use that everywhere internally.  One difference is that log1p is only used in cmath and math, while hypot is also needed in the Python core.
msg174198 - (view) Author: Václav Šmilauer (eudoxos) * Date: 2012-10-30 10:19
Just for the record: a workaround (mentioned at http://boost.2283326.n4.nabble.com/Boost-Python-Compile-Error-s-GCC-via-MinGW-w64-td3165793.html#a3166760) is to always include <cmath> before <Python.h>.
msg174366 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-10-31 20:33
Is this also an issue for Python 3.x?
msg174397 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-11-01 10:41
In general, including standard library headers before including Python.h is not recommended, since it may break binary compatibility across object files. So the proposed work-around may also cause harm.
msg175568 - (view) Author: Václav Šmilauer (eudoxos) * Date: 2012-11-14 13:17
Martin, I know it is not a proper fix. OTOH, Python is not the only project which "recommends" its header be included as first.

I don't know if it is an issue for Python 3.x; will try to test that. This bug, though, is clearly reported about Python 2.7, which IS in bug-fix mode.
msg201101 - (view) Author: Heinrich Kießling (pokulo) Date: 2013-10-24 08:56
uning python 3.3 mingw4.8 both -std=gnu++0x and -std=c++11 cause still the same error.
msg272475 - (view) Author: Kay Hayen (Kay.Hayen) Date: 2016-08-11 18:48
This also affects Python2.7.12 on Windows with latest MinGW. I think something similar needs to be added for GCC version check:

/* VS 2010 and above already defines hypot as _hypot */
#if _MSC_VER < 1600
#define hypot _hypot
#endif

Not sure which gcc version first had that, but 6.1 definitely does.

Yours,
Kay
msg290754 - (view) Author: Matthew McCormick (thewtex) * Date: 2017-03-28 19:49
I have created a pull request for this issue,

  https://github.com/python/cpython/pull/880

that addresses extension builds for both MinGWPy and the Microsoft Visual C++ Compiler for Python 2.7.
msg332293 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2018-12-21 15:35
The change in PR 880 looks fine to me. I dislike defining names without a Py prefix in public headers.

And PRs are not where we do general discussion or ping for attention. Make sure the nosy list includes the relevant experts (in this case probably me) and post on the issue. Posting on python-dev is also okay, though linking the bug is preferable to the PR.
msg332295 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-12-21 16:17
What current 3.x versions have this issue?  This issue was opened against 2.7.  This was changed to 3.3 in 2013 (3.3 should have just been added with control-click).  I reverted to 2.7 and tentatively added 3.8, but this needs to be checked.

The PR is against 2.7, though not so marked in the title.  (I will fix this.)  Since the move to GitHub, we usually fix on master first and then backport.

Something is not right with the PR 880 linkage.  For me, anyway, Steve's reference is actually linked to 10880 (closed).
msg332301 - (view) Author: Matthew McCormick (thewtex) * Date: 2018-12-21 21:02
> What current 3.x versions have this issue?  This issue was opened against 2.7.

Yes, this is just for 2.7.
msg332436 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:04
New changeset 87667c54c6650751c5d7bf7b9e465c8c4af45f71 by INADA Naoki (Matt McCormick) in branch 'master':
bpo-11566: Extension build errors on Windows for _hypot (GH-11283)
https://github.com/python/cpython/commit/87667c54c6650751c5d7bf7b9e465c8c4af45f71
msg332437 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:05
New changeset 87667c54c6650751c5d7bf7b9e465c8c4af45f71 by INADA Naoki (Matt McCormick) in branch 'master':
bpo-11566: Extension build errors on Windows for _hypot (GH-11283)
https://github.com/python/cpython/commit/87667c54c6650751c5d7bf7b9e465c8c4af45f71
msg332438 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:06
New changeset 87667c54c6650751c5d7bf7b9e465c8c4af45f71 by INADA Naoki (Matt McCormick) in branch 'master':
bpo-11566: Extension build errors on Windows for _hypot (GH-11283)
https://github.com/python/cpython/commit/87667c54c6650751c5d7bf7b9e465c8c4af45f71
msg332439 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:06
New changeset 87667c54c6650751c5d7bf7b9e465c8c4af45f71 by INADA Naoki (Matt McCormick) in branch 'master':
bpo-11566: Extension build errors on Windows for _hypot (GH-11283)
https://github.com/python/cpython/commit/87667c54c6650751c5d7bf7b9e465c8c4af45f71
msg332440 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:07
New changeset 87667c54c6650751c5d7bf7b9e465c8c4af45f71 by INADA Naoki (Matt McCormick) in branch 'master':
bpo-11566: Extension build errors on Windows for _hypot (GH-11283)
https://github.com/python/cpython/commit/87667c54c6650751c5d7bf7b9e465c8c4af45f71
msg332441 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:07
New changeset 87667c54c6650751c5d7bf7b9e465c8c4af45f71 by INADA Naoki (Matt McCormick) in branch 'master':
bpo-11566: Extension build errors on Windows for _hypot (GH-11283)
https://github.com/python/cpython/commit/87667c54c6650751c5d7bf7b9e465c8c4af45f71
msg332442 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:08
New changeset 87667c54c6650751c5d7bf7b9e465c8c4af45f71 by INADA Naoki (Matt McCormick) in branch 'master':
bpo-11566: Extension build errors on Windows for _hypot (GH-11283)
https://github.com/python/cpython/commit/87667c54c6650751c5d7bf7b9e465c8c4af45f71
msg332443 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:09
New changeset 87667c54c6650751c5d7bf7b9e465c8c4af45f71 by INADA Naoki (Matt McCormick) in branch 'master':
bpo-11566: Extension build errors on Windows for _hypot (GH-11283)
https://github.com/python/cpython/commit/87667c54c6650751c5d7bf7b9e465c8c4af45f71
msg332444 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:09
New changeset 87667c54c6650751c5d7bf7b9e465c8c4af45f71 by INADA Naoki (Matt McCormick) in branch 'master':
bpo-11566: Extension build errors on Windows for _hypot (GH-11283)
https://github.com/python/cpython/commit/87667c54c6650751c5d7bf7b9e465c8c4af45f71
msg332445 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:10
New changeset 87667c54c6650751c5d7bf7b9e465c8c4af45f71 by INADA Naoki (Matt McCormick) in branch 'master':
bpo-11566: Extension build errors on Windows for _hypot (GH-11283)
https://github.com/python/cpython/commit/87667c54c6650751c5d7bf7b9e465c8c4af45f71
msg332446 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:11
New changeset 000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f by INADA Naoki (Matt McCormick) in branch '2.7':
bpo-11566: Remove hypot -> _hypot macro for very old compilers (GH-11283)
https://github.com/python/cpython/commit/000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f
msg332447 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:12
New changeset 87667c54c6650751c5d7bf7b9e465c8c4af45f71 by INADA Naoki (Matt McCormick) in branch 'master':
bpo-11566: Extension build errors on Windows for _hypot (GH-11283)
https://github.com/python/cpython/commit/87667c54c6650751c5d7bf7b9e465c8c4af45f71
msg332448 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:12
New changeset 000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f by INADA Naoki (Matt McCormick) in branch '2.7':
bpo-11566: Remove hypot -> _hypot macro for very old compilers (GH-11283)
https://github.com/python/cpython/commit/000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f
msg332449 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:13
New changeset 000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f by INADA Naoki (Matt McCormick) in branch '2.7':
bpo-11566: Remove hypot -> _hypot macro for very old compilers (GH-11283)
https://github.com/python/cpython/commit/000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f
msg332450 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:13
New changeset 000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f by INADA Naoki (Matt McCormick) in branch '2.7':
bpo-11566: Remove hypot -> _hypot macro for very old compilers (GH-11283)
https://github.com/python/cpython/commit/000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f
msg332451 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:14
New changeset 000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f by INADA Naoki (Matt McCormick) in branch '2.7':
bpo-11566: Remove hypot -> _hypot macro for very old compilers (GH-11283)
https://github.com/python/cpython/commit/000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f
msg332452 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:15
New changeset 87667c54c6650751c5d7bf7b9e465c8c4af45f71 by INADA Naoki (Matt McCormick) in branch 'master':
bpo-11566: Extension build errors on Windows for _hypot (GH-11283)
https://github.com/python/cpython/commit/87667c54c6650751c5d7bf7b9e465c8c4af45f71
msg332453 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:18
New changeset 000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f by INADA Naoki (Matt McCormick) in branch '2.7':
bpo-11566: Remove hypot -> _hypot macro for very old compilers (GH-11283)
https://github.com/python/cpython/commit/000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f
msg332454 - (view) Author: miss-islington (miss-islington) Date: 2018-12-24 14:18
New changeset c046d6b6187e4de98a29e67ccbfd9b1b8790ee2f by Miss Islington (bot) in branch '3.7':
bpo-11566: Extension build errors on Windows for _hypot (GH-11283)
https://github.com/python/cpython/commit/c046d6b6187e4de98a29e67ccbfd9b1b8790ee2f
msg332455 - (view) Author: miss-islington (miss-islington) Date: 2018-12-24 14:19
New changeset c046d6b6187e4de98a29e67ccbfd9b1b8790ee2f by Miss Islington (bot) in branch '3.7':
bpo-11566: Extension build errors on Windows for _hypot (GH-11283)
https://github.com/python/cpython/commit/c046d6b6187e4de98a29e67ccbfd9b1b8790ee2f
msg332460 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 14:54
New changeset 000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f by INADA Naoki (Matt McCormick) in branch '2.7':
bpo-11566: Remove hypot -> _hypot macro for very old compilers (GH-11283)
https://github.com/python/cpython/commit/000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f
msg332475 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 16:06
New changeset 000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f by INADA Naoki (Matt McCormick) in branch '2.7':
bpo-11566: Remove hypot -> _hypot macro for very old compilers (GH-11283)
https://github.com/python/cpython/commit/000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f
msg332476 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 16:06
New changeset 000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f by INADA Naoki (Matt McCormick) in branch '2.7':
bpo-11566: Remove hypot -> _hypot macro for very old compilers (GH-11283)
https://github.com/python/cpython/commit/000b8093a13f1c5bfe4b65a4dc1b23e0db553a8f
msg332477 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-12-24 16:06
New changeset 87667c54c6650751c5d7bf7b9e465c8c4af45f71 by INADA Naoki (Matt McCormick) in branch 'master':
bpo-11566: Extension build errors on Windows for _hypot (GH-11283)
https://github.com/python/cpython/commit/87667c54c6650751c5d7bf7b9e465c8c4af45f71
History
Date User Action Args
2022-04-11 14:57:14adminsetgithub: 55775
2018-12-24 16:06:59methanesetmessages: + msg332477
2018-12-24 16:06:37methanesetmessages: + msg332476
2018-12-24 16:06:13methanesetmessages: + msg332475
2018-12-24 14:54:38methanesetmessages: + msg332460
2018-12-24 14:19:31miss-islingtonsetnosy: + miss-islington
messages: + msg332455
2018-12-24 14:19:05miss-islingtonsetnosy: + miss-islington
messages: + msg332454
2018-12-24 14:18:46methanesetmessages: + msg332453
2018-12-24 14:15:19methanesetmessages: + msg332452
2018-12-24 14:14:40methanesetmessages: + msg332451
2018-12-24 14:13:46methanesetmessages: + msg332450
2018-12-24 14:13:24methanesetmessages: + msg332449
2018-12-24 14:12:35methanesetmessages: + msg332448
2018-12-24 14:12:17methanesetmessages: + msg332447
2018-12-24 14:11:57methanesetmessages: + msg332446
2018-12-24 14:10:07methanesetmessages: + msg332445
2018-12-24 14:09:35methanesetmessages: + msg332444
2018-12-24 14:09:10methanesetmessages: + msg332443
2018-12-24 14:08:24methanesetmessages: + msg332442
2018-12-24 14:07:51methanesetmessages: + msg332441
2018-12-24 14:07:29methanesetmessages: + msg332440
2018-12-24 14:07:17miss-islingtonsetpull_requests: + pull_request10530
2018-12-24 14:06:54methanesetmessages: + msg332439
2018-12-24 14:06:37methanesetmessages: + msg332438
2018-12-24 14:05:59methanesetmessages: + msg332437
2018-12-24 14:04:52methanesetnosy: + methane
messages: + msg332436
2018-12-24 14:00:05thewtexsetpull_requests: + pull_request10529
2018-12-22 01:42:25methanesetstatus: open -> closed
stage: resolved
resolution: fixed
versions: + Python 3.7, Python 3.8
2018-12-21 21:31:26kayhayensetnosy: - Kay.Hayen
2018-12-21 21:02:16thewtexsetmessages: + msg332301
versions: - Python 3.8
2018-12-21 16:17:53terry.reedysetnosy: + terry.reedy

messages: + msg332295
versions: + Python 2.7, Python 3.8, - Python 3.3
2018-12-21 15:35:23steve.dowersetnosy: + steve.dower
messages: + msg332293
2018-03-20 10:54:27jdemeyersetnosy: + jdemeyer
2017-03-28 19:49:47thewtexsetnosy: + thewtex
messages: + msg290754
2017-03-28 19:48:57thewtexsetpull_requests: + pull_request780
2016-08-16 06:22:00petri.lehtinensetnosy: - petri.lehtinen
2016-08-15 13:24:01passetnosy: + pas
2016-08-11 18:48:54Kay.Hayensetnosy: + Kay.Hayen
messages: + msg272475
2013-10-24 09:54:49tim.goldensetnosy: - tim.golden
2013-10-24 08:56:56pokulosetnosy: + pokulo

messages: + msg201101
versions: + Python 3.3, - Python 2.7
2012-11-14 13:17:31eudoxossetmessages: + msg175568
2012-11-01 10:41:27loewissetmessages: + msg174397
2012-10-31 20:33:35mark.dickinsonsetmessages: + msg174366
2012-10-30 10:19:42eudoxossetmessages: + msg174198
2012-10-30 10:16:11mark.dickinsonsetmessages: + msg174197
2012-10-30 09:33:59mark.dickinsonsetnosy: + mark.dickinson
2012-10-29 22:45:34eudoxossetnosy: + eudoxos
messages: + msg174157
2012-10-11 19:52:28schmirsetmessages: + msg172684
2012-10-11 19:44:59petri.lehtinensetnosy: + loewis, tim.golden, brian.curtin
messages: + msg172683
components: + Windows, - None
2012-10-11 19:02:20schmirsetstatus: pending -> open

messages: + msg172675
2012-10-11 18:59:48petri.lehtinensetstatus: open -> pending
nosy: + petri.lehtinen
messages: + msg172674

2011-03-15 23:39:14schmircreate