Title: pyport.h uses non C90-style comment
Type: compile error Stage:
Components: Versions: Python 3.6
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Sander Vrijders, benjamin.peterson, serhiy.storchaka, vstinner, xiang.zhang
Priority: normal Keywords:

Created on 2017-01-09 14:28 by Sander Vrijders, last changed 2017-01-11 05:09 by xiang.zhang. This issue is now closed.

Messages (6)
msg285045 - (view) Author: Sander Vrijders (Sander Vrijders) Date: 2017-01-09 14:28
I am writing C90 compliant code and am wrapping my C headers with SWIG, which includes python3.6m/pyport.h. I've told my compiler to report all warnings as errors. Compilation fails with the following error:

/usr/include/python3.6m/pyport.h:40:1: error: C++ style comments are not allowed in ISO C90
 // long long is required. Ensure HAVE_LONG_LONG is defined for compatibility.

I believe the comment was added by the patch of a previous bug (see The solution would be to change this comment to a C90 comment.
msg285048 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-01-09 15:47
That's a change in 3.6, see
msg285049 - (view) Author: Sander Vrijders (Sander Vrijders) Date: 2017-01-09 16:11
Okay, a bit conflicted about the following though. The changelog refers to PEP7. This document indeed states that Python versions greater than or equal to 3.6 use C89 with several select C99 features, such as C++-style line comments. But then below that it has a rule that says never use C++ style // one-line comments. That seems contradictory.

FYI, I mean not complaining about stdint.h, gcc (and clang) also support those with the C90 switch turned on. 

Or should I just assume that all headers are henceforth C99 and any wrapping code should also be C99? Though it seems a bit overkill to kill all compatibility for a single comment line. If I use a C89 comment on my system the build works perfectly.
msg285050 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-01-09 16:21
I found that conflict once but lost it then. :-(

> Or should I just assume that all headers are henceforth C99 and any wrapping code should also be C99?

I am not sure. :-( Nosy other experts. :-)
msg285095 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2017-01-10 07:15
C99 is required to build or include Python headers since 3.6. PEP 7 could be clearer. The bullet about C99 is meant to override for 3.6 other directives such as the comment prohibition.
msg285186 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-01-11 05:09
About the comment style confliction, I opened an issue on Github and assigned to you Benjamin.
Date User Action Args
2017-01-11 05:09:13xiang.zhangsetmessages: + msg285186
2017-01-10 07:15:32benjamin.petersonsetstatus: open -> closed
resolution: not a bug
messages: + msg285095
2017-01-09 16:31:16serhiy.storchakasetnosy: + benjamin.peterson
2017-01-09 16:21:36xiang.zhangsetnosy: + vstinner, serhiy.storchaka
messages: + msg285050
2017-01-09 16:11:42Sander Vrijderssetmessages: + msg285049
2017-01-09 15:47:44xiang.zhangsetnosy: + xiang.zhang
messages: + msg285048
2017-01-09 14:28:49Sander Vrijderscreate