Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: implicit declaration of function '_setmode' #72954

Closed
ma8ma mannequin opened this issue Nov 21, 2016 · 9 comments
Closed

Warning: implicit declaration of function '_setmode' #72954

ma8ma mannequin opened this issue Nov 21, 2016 · 9 comments
Labels
3.7 (EOL) end of life build The build process and cross-build OS-windows

Comments

@ma8ma
Copy link
Mannequin

ma8ma mannequin commented Nov 21, 2016

BPO 28768
Nosy @pfmoore, @vstinner, @tjguk, @benjaminp, @vadmium, @zware, @zooba, @ma8ma
PRs
  • [Do Not Merge] Convert Misc/NEWS so that it is managed by towncrier #552
  • Files
  • include-io.h.patch
  • 2.7-include-io.h.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2017-01-04.16:00:39.202>
    created_at = <Date 2016-11-21.20:00:30.849>
    labels = ['build', '3.7', 'OS-windows']
    title = "Warning: implicit declaration of function '_setmode'"
    updated_at = <Date 2017-03-31.16:36:34.322>
    user = 'https://github.com/ma8ma'

    bugs.python.org fields:

    activity = <Date 2017-03-31.16:36:34.322>
    actor = 'dstufft'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-01-04.16:00:39.202>
    closer = 'vstinner'
    components = ['Build', 'Windows']
    creation = <Date 2016-11-21.20:00:30.849>
    creator = 'masamoto'
    dependencies = []
    files = ['45592', '45593']
    hgrepos = []
    issue_num = 28768
    keywords = ['patch']
    message_count = 9.0
    messages = ['281389', '281470', '281472', '284210', '284211', '284566', '284616', '284645', '284646']
    nosy_count = 10.0
    nosy_names = ['paul.moore', 'vstinner', 'tim.golden', 'benjamin.peterson', 'stutzbach', 'python-dev', 'martin.panter', 'zach.ware', 'steve.dower', 'masamoto']
    pr_nums = ['552']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'commit review'
    status = 'closed'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue28768'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7']

    @ma8ma
    Copy link
    Mannequin Author

    ma8ma mannequin commented Nov 21, 2016

    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.

    [*] https://msdn.microsoft.com/en-us/library/tw4k6df8.aspx (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);
    ^

    @ma8ma ma8ma mannequin added 3.7 (EOL) end of life build The build process and cross-build labels Nov 21, 2016
    @vadmium
    Copy link
    Member

    vadmium commented Nov 22, 2016

    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, configure.ac optionally enables HAVE_IO_H, and there are various other conditions in different files, like as QUICKWIN, PYCC_VACPP and MS_WINDOWS || __CYGWIN__.

    @vstinner
    Copy link
    Member

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 28, 2016

    New changeset 5027780d456b by Steve Dower in branch '3.6':
    Issue bpo-28768: Fix implicit declaration of function _setmode. Patch by Masayuki Yamamoto
    https://hg.python.org/cpython/rev/5027780d456b

    New changeset 276d1bae92be by Steve Dower in branch 'default':
    Issue bpo-28768: Fix implicit declaration of function _setmode. Patch by Masayuki Yamamoto
    https://hg.python.org/cpython/rev/276d1bae92be

    @zooba
    Copy link
    Member

    zooba commented Dec 28, 2016

    I applied to 3.6 and default. If anyone is motivated enough to apply to 2.7, feel free.

    @vstinner
    Copy link
    Member

    vstinner commented Jan 3, 2017

    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?

    @ma8ma
    Copy link
    Mannequin Author

    ma8ma mannequin commented Jan 4, 2017

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 4, 2017

    New changeset 5ea0fef6ec53 by Steve Dower in branch '2.7':
    Issue bpo-28768: Fix implicit declaration of function _setmode. Patch by Masayuki Yamamoto
    https://hg.python.org/cpython/rev/5ea0fef6ec53

    @vstinner
    Copy link
    Member

    vstinner commented Jan 4, 2017

    Well, the change is not going to hurt. I backported the change. Thanks for the fix Masayuki!

    @vstinner vstinner closed this as completed Jan 4, 2017
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life build The build process and cross-build OS-windows
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants