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.

Title: Warning: implicit declaration of function '_setmode'
Type: compile error Stage: commit review
Components: Build, Windows Versions: Python 3.7, Python 3.6, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, martin.panter, masamoto, paul.moore, python-dev, steve.dower, stutzbach, tim.golden, vstinner, zach.ware
Priority: normal Keywords: patch

Created on 2016-11-21 20:00 by masamoto, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
include-io.h.patch masamoto, 2016-11-21 20:00 review
2.7-include-io.h.patch masamoto, 2016-11-21 20:00 review
Pull Requests
URL Status Linked Edit
PR 552 closed dstufft, 2017-03-31 16:36
Messages (9)
msg281389 - (view) Author: Masayuki Yamamoto (masamoto) * Date: 2016-11-21 20:00
Platform that appeared warning is Vista Cygwin x86. Interpreter execution doesn't crash because _setmode function is supplied from cygwin1.dll that always linked.
Warning reason is header io.h [*] doesn't include to source file. Therefore I wrote two patches for 3.7 and 2.7.

[*] (Cygwin also avaliable)

build log on 3.7:

gcc -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers   -I. -I./Include    -DPy_BUILD_CORE -o Modules/main.o Modules/main.c
Modules/main.c: In function 'Py_Main':
Modules/main.c:599:5: warning: implicit declaration of function '_setmode' [-Wimplicit-function-declaration]
     _setmode(fileno(stdin), O_BINARY);
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers   -I. -I./Include    -DPy_BUILD_CORE  -I./Modules/_io -c ./Modules/_io/fileio.c -o Modules/fileio.o
./Modules/_io/fileio.c: In function '_io_FileIO___init___impl':
./Modules/_io/fileio.c:478:5: warning: implicit declaration of function '_setmode' [-Wimplicit-function-declaration]
     _setmode(self->fd, O_BINARY);
msg281470 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-11-22 12:07
The Modules/main.c change at least looks reasonable as a bug fix.

In the long term, it would be nice to clean up some of the conditions for including <io.h>. Currently it is unconditional via PC/pyconfig.h, optionally enables HAVE_IO_H, and there are various other conditions in different files, like as QUICKWIN, PYCC_VACPP and MS_WINDOWS || __CYGWIN__.
msg281472 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-11-22 12:14
include-io.h.patch LGTM.

2.7-include-io.h.patch: Cygwin is not currently officially supported in CPython. I suggest to focus efforts on supporting Cygwin in the default branch (future 3.7) only, as we are doing with Android.
msg284210 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-12-28 23:42
New changeset 5027780d456b by Steve Dower in branch '3.6':
Issue #28768: Fix implicit declaration of function _setmode. Patch by Masayuki Yamamoto

New changeset 276d1bae92be by Steve Dower in branch 'default':
Issue #28768: Fix implicit declaration of function _setmode. Patch by Masayuki Yamamoto
msg284211 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-12-28 23:42
I applied to 3.6 and default. If anyone is motivated enough to apply to 2.7, feel free.
msg284566 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-01-03 14:12
Masayuki Yamamoto: Do you consider that Python 2.7 should be fixed as well? What is your use case for compiling Python 2.7 on Windows using Cygwin?
msg284616 - (view) Author: Masayuki Yamamoto (masamoto) * Date: 2017-01-04 06:47
Building 2.7 is for testing purposes. It is used to judge whether it is a problem (specifically for Cygwin-specific) originated in the old version. _setmode is an important function for setting input and output of CPython, so in Cygwin I feel annoying that warnings are issued even though there is actually no problem.
msg284645 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2017-01-04 15:59
New changeset 5ea0fef6ec53 by Steve Dower in branch '2.7':
Issue #28768: Fix implicit declaration of function _setmode. Patch by Masayuki Yamamoto
msg284646 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-01-04 16:00
Well, the change is not going to hurt. I backported the change. Thanks for the fix Masayuki!
Date User Action Args
2022-04-11 14:58:39adminsetgithub: 72954
2017-03-31 16:36:34dstufftsetpull_requests: + pull_request1071
2017-01-04 16:00:39vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg284646
2017-01-04 15:59:56python-devsetmessages: + msg284645
2017-01-04 06:47:48masamotosetmessages: + msg284616
2017-01-03 14:12:46vstinnersetmessages: + msg284566
2016-12-28 23:42:29steve.dowersetmessages: + msg284211
stage: patch review -> commit review
2016-12-28 23:42:04python-devsetnosy: + python-dev
messages: + msg284210
2016-11-22 12:14:52vstinnersetnosy: + vstinner
messages: + msg281472
2016-11-22 12:07:09martin.pantersetnosy: + zach.ware, paul.moore, tim.golden, martin.panter, steve.dower
messages: + msg281470

components: + Windows
stage: patch review
2016-11-21 20:00:58masamotosetfiles: + 2.7-include-io.h.patch
2016-11-21 20:00:30masamotocreate