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

Fix _tkinter compiler warnings on MSVC #66334

Closed
zware opened this issue Aug 4, 2014 · 11 comments
Closed

Fix _tkinter compiler warnings on MSVC #66334

zware opened this issue Aug 4, 2014 · 11 comments
Assignees
Labels
build The build process and cross-build OS-windows topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@zware
Copy link
Member

zware commented Aug 4, 2014

BPO 22136
Nosy @loewis, @zware, @serhiy-storchaka
Files
  • tkinter_MSVC_warnings.diff
  • 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 = 'https://github.com/zware'
    closed_at = <Date 2014-08-05.16:55:10.949>
    created_at = <Date 2014-08-04.21:06:58.056>
    labels = ['type-bug', 'expert-tkinter', 'OS-windows', 'build']
    title = 'Fix _tkinter compiler warnings on MSVC'
    updated_at = <Date 2014-08-05.16:56:58.190>
    user = 'https://github.com/zware'

    bugs.python.org fields:

    activity = <Date 2014-08-05.16:56:58.190>
    actor = 'zach.ware'
    assignee = 'zach.ware'
    closed = True
    closed_date = <Date 2014-08-05.16:55:10.949>
    closer = 'python-dev'
    components = ['Build', 'Tkinter', 'Windows']
    creation = <Date 2014-08-04.21:06:58.056>
    creator = 'zach.ware'
    dependencies = []
    files = ['36261']
    hgrepos = []
    issue_num = 22136
    keywords = ['patch']
    message_count = 11.0
    messages = ['224776', '224809', '224820', '224827', '224829', '224840', '224843', '224845', '224851', '224859', '224860']
    nosy_count = 4.0
    nosy_names = ['loewis', 'python-dev', 'zach.ware', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue22136'
    versions = ['Python 3.5']

    @zware
    Copy link
    Member Author

    zware commented Aug 4, 2014

    Dropping support of Tk 8.3 caused a few compiler warnings on Windows:

    ..\Modules\_tkinter.c(587): warning C4090: '=' : different 'const' qualifiers
    ..\Modules\_tkinter.c(588): warning C4090: '=' : different 'const' qualifiers
    ..\Modules\_tkinter.c(589): warning C4090: '=' : different 'const' qualifiers
    ..\Modules\_tkinter.c(590): warning C4090: '=' : different 'const' qualifiers
    ..\Modules\_tkinter.c(591): warning C4090: '=' : different 'const' qualifiers
    ..\Modules\_tkinter.c(592): warning C4090: '=' : different 'const' qualifiers
    ..\Modules\_tkinter.c(593): warning C4090: '=' : different 'const' qualifiers

    Does this patch look like the correct fix?

    @zware zware added build The build process and cross-build topic-tkinter OS-windows type-bug An unexpected behavior, bug, or error labels Aug 4, 2014
    @serhiy-storchaka
    Copy link
    Member

    I'm surprised that this caused a warning. In man page Tcl_GetObjType() is described as

       Tcl_ObjType *
       Tcl_GetObjType(typeName)
    

    and in header file it is declared as

    EXTERN Tcl_ObjType * Tcl_GetObjType _ANSI_ARGS_((char * typeName));
    Tcl_ObjType *Tcl_GetObjType(typeName);

    But this change shouldn't add any ill effect. The patch LGTM.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Aug 5, 2014

    Serhiy: See

    http://svn.python.org/projects/external/tcl-8.6.1.0/generic/tclDecls.h

    where it now is

    EXTERN CONST86 Tcl_ObjType * Tcl_GetObjType(const char *typeName);

    I think the patch is wrong as it stands, as "const" is not a reserved word in C89. Instead, you should be using something like

    #ifndef CONST86
    #define CONST86
    #endif

    Tcl_ObjType CONST86 *BooleanType;

    @serhiy-storchaka
    Copy link
    Member

    Serhiy: See
    http://svn.python.org/projects/external/tcl-8.6.1.0/generic/tclDecls.h
    where it now is
    EXTERN CONST86 Tcl_ObjType * Tcl_GetObjType(const char *typeName);

    Oh, my fault. I did not notice that my tcl workspace was switched to 8.3
    branch.

    I think the patch is wrong as it stands, as "const" is not a reserved word
    in C89.

    "const" was introduced in ANSI C (aka C89) and it is reserved word. The patch
    is correct because even if Tcl_GetObjType() returns "Tcl_ObjType *", the
    result is compatible with "Tcl_ObjType const *" (or "const Tcl_ObjType *").

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Aug 5, 2014

    I see. So the patch is fine indeed.

    @zware
    Copy link
    Member Author

    zware commented Aug 5, 2014

    Thank you both for the reviews!

    Embarrassingly, I just realized that I didn't post the patch I meant to; in quickly reconstructing the patch after accidentally destroying a previous version, I made it "Tcl_ObjType const *SomeType;" instead of "const Tcl_ObjType *SomeType;". It seems to me that "const <type>" is much more common than "<type> const"; does it actually matter which way it goes? Either way fixes the warnings.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Aug 5, 2014

    "const T" and "T const" are the same type. This compiles, and all variables have the same type:

    int main()
    {
      const volatile int a;
      const int volatile b;
      int const volatile c;
      volatile int const d;
      volatile int const etc;
    }

    Even "volatile short const int" and "long volatile long const int" work.

    @zware
    Copy link
    Member Author

    zware commented Aug 5, 2014

    I see. There doesn't appear to be anything in PEP-7 about this; do we have a style preference for this that applies here? Or should I just shut up and commit it? :)

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Aug 5, 2014

    Grepping through the source shows that currently, the const always goes before the type (for char, wchar_t, Py_UCS2, and int). So please do this style adjustment and commit.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 5, 2014

    New changeset 7ed237478fcc by Zachary Ware in branch 'default':
    Closes bpo-22136: Fix MSVC compiler warnings introduced by bpo-22085
    http://hg.python.org/cpython/rev/7ed237478fcc

    @python-dev python-dev mannequin closed this as completed Aug 5, 2014
    @zware
    Copy link
    Member Author

    zware commented Aug 5, 2014

    Done and done. Thank you very much, Martin.

    @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
    build The build process and cross-build OS-windows topic-tkinter type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants