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: clang warns "warning: redefinition of typedef 'PyTypeObject' is a C11 feature [-Wtypedef-redefinition]"
Type: Stage: resolved
Components: C API Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: colesbury, vstinner
Priority: normal Keywords: patch

Created on 2020-02-06 17:09 by colesbury, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18385 merged vstinner, 2020-02-06 22:16
Messages (7)
msg361497 - (view) Author: Sam Gross (colesbury) * (Python triager) Date: 2020-02-06 17:09
A recent commit added a typedef for PyTypeObject in Include/object.h

https://github.com/python/cpython/commit/0e4e735d06967145b49fd00693627f3624991dbc

This duplicates the typedef in Include/cpython/object.h. Building with clang now issues a warning:

./Include/cpython/object.h:274:3: warning: redefinition of typedef 'PyTypeObject' is a C11 feature [-Wtypedef-redefinition]

This is due to the combination of `-Wall` and `-std=c99`. GCC will only warn if the `-pedantic` option is specified.
msg361506 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-02-06 22:09
Sorry, I only tested GCC and I forgot that clang is more pedantic on duplicated typedef. I looked better with PyTypeObject, but the fix is easy: just revert my change: PR 18384.
msg361507 - (view) Author: Sam Gross (colesbury) * (Python triager) Date: 2020-02-06 22:14
Alternatively I think you can just remove the typedef from Include/cpython/object.h since Include/object.h is always included first. i.e.:

typedef struct _typeobject {
  ...
} PyTypeObject;

to simply

struct _typeobject {
  ...
};
msg361509 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-02-06 22:17
> Alternatively I think you can just remove the typedef from Include/cpython/object.h since Include/object.h is always included first. i.e.:

Oh, nice! I proposed PR 18385. Would you mind to confirm that it fix the issue for you? At least, I tested manually and the clang warning goes away with this change.
msg361512 - (view) Author: Sam Gross (colesbury) * (Python triager) Date: 2020-02-06 22:45
Yes, that fixes the warnings for me. Thanks!
msg361520 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-02-07 00:43
New changeset f95cd199b4bc16775c8c48641bd85416b17742e7 by Victor Stinner in branch 'master':
bpo-39571: Fix clang warning on PyTypeObject typedef (GH-18385)
https://github.com/python/cpython/commit/f95cd199b4bc16775c8c48641bd85416b17742e7
msg361521 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-02-07 00:49
Thanks Sam Gross for the hint, it's now fixed.
History
Date User Action Args
2022-04-11 14:59:26adminsetgithub: 83752
2020-02-07 00:49:45vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg361521

stage: patch review -> resolved
2020-02-07 00:43:37vstinnersetmessages: + msg361520
2020-02-06 22:45:39colesburysetmessages: + msg361512
2020-02-06 22:17:12vstinnersetmessages: + msg361509
2020-02-06 22:16:25vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request17759
2020-02-06 22:14:10colesburysetmessages: + msg361507
2020-02-06 22:09:52vstinnersetmessages: + msg361506
2020-02-06 17:09:39colesburycreate