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

No warning on conflicting definitions #1874

Closed
Nikratio opened this Issue Sep 15, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@Nikratio
Contributor

Nikratio commented Sep 15, 2017

On mips, the st_rdev and st_dev fields of struct stat are of type long unsigned int rather than dev_t for $REASONS. The posix/stat.pxd file shipped with Cython correctly defines them as dev_t. To get my source code to compile under mips, I therefore thought I'd just teach Cython about this peculiarity:

from posix.stat cimport *
cdef extern from "<sys/stat.h>" nogil:
    cdef struct struct_mstat "stat":
        int   st_dev
        ino_t   st_ino
        mode_t  st_mode
        nlink_t st_nlink
        uid_t   st_uid
        gid_t   st_gid
        int st_rdev
        off_t   st_size
        blksize_t st_blksize
        blkcnt_t st_blocks
        time_t  st_atime
        time_t  st_mtime
        time_t  st_ctime

However, this did not have any effect at all. On further investigation, renaming eg st_ino to st_ino_fo did not result in any warnings either.

It seems to me that Cython silently uses its own definition of struct stat, and ignores everything that attempts to re-define it. I would have expected that a more local declaration takes predecence. But even more important, I think Cython should at least warn if it encounters such a conflicting definition.

@robertwb

This comment has been minimized.

Show comment
Hide comment
@robertwb

robertwb Oct 13, 2017

Contributor

It is a warning, though not a very verbose one.

warning(pos, "'%s' redeclared " % name, 0)
I'd be very much in favor of making this louder, possibly eventually an error. The issue is some projects rely on being able to re-declare things (e.g. they use pxi files that have definitions that get included multiple times).

Contributor

robertwb commented Oct 13, 2017

It is a warning, though not a very verbose one.

warning(pos, "'%s' redeclared " % name, 0)
I'd be very much in favor of making this louder, possibly eventually an error. The issue is some projects rely on being able to re-declare things (e.g. they use pxi files that have definitions that get included multiple times).

@jdemeyer

This comment has been minimized.

Show comment
Hide comment
@jdemeyer

jdemeyer Nov 13, 2017

Contributor

While compiling Cython itself, this gives

    warning: Cython/Compiler/Code.py:380:4: 'format_code' redeclared
    warning: Cython/Compiler/Code.py:442:4: 'none_or_sub' redeclared
    warning: Cython/Compiler/Code.py:693:4: 'new_label' redeclared
    warning: Cython/Compiler/Code.py:712:4: 'get_loop_labels' redeclared
    warning: Cython/Compiler/Code.py:717:4: 'set_loop_labels' redeclared
    warning: Cython/Compiler/Code.py:728:4: 'get_all_labels' redeclared
    warning: Cython/Compiler/Code.py:735:4: 'set_all_labels' redeclared
    warning: Cython/Compiler/Code.py:826:4: 'temps_in_use' redeclared
    warning: Cython/Compiler/Code.py:863:4: 'start_collecting_temps' redeclared
    warning: Cython/Compiler/Code.py:869:4: 'stop_collecting_temps' redeclared
    warning: Cython/Compiler/Code.py:930:4: 'get_py_string_const' redeclared
    warning: Cython/Compiler/FlowControl.py:74:4: 'empty' redeclared
    warning: Cython/Compiler/FlowControl.py:77:4: 'detach' redeclared
    warning: Cython/Compiler/FlowControl.py:86:4: 'add_child' redeclared
    warning: Cython/Compiler/FlowControl.py:94:4: 'empty' redeclared
    warning: Cython/Compiler/FlowControl.py:126:4: 'newblock' redeclared
    warning: Cython/Compiler/FlowControl.py:137:4: 'nextblock' redeclared
    warning: Cython/Compiler/FlowControl.py:151:4: 'is_tracked' redeclared
    warning: Cython/Compiler/FlowControl.py:158:4: 'is_statically_assigned' redeclared
    warning: Cython/Compiler/FlowControl.py:168:4: 'mark_position' redeclared
    warning: Cython/Compiler/FlowControl.py:173:4: 'mark_assignment' redeclared
    warning: Cython/Compiler/FlowControl.py:180:4: 'mark_argument' redeclared
    warning: Cython/Compiler/FlowControl.py:187:4: 'mark_deletion' redeclared
    warning: Cython/Compiler/FlowControl.py:194:4: 'mark_reference' redeclared
    warning: Cython/Compiler/FlowControl.py:204:4: 'normalize' redeclared
    warning: Cython/Compiler/FlowControl.py:227:4: 'initialize' redeclared
    warning: Cython/Compiler/FlowControl.py:263:4: 'map_one' redeclared
    warning: Cython/Compiler/FlowControl.py:763:4: 'mark_assignment' redeclared
    warning: Cython/Compiler/FlowControl.py:796:4: 'mark_position' redeclared
    warning: Cython/Compiler/Parsing.py:646:0: 'make_slice_node' redeclared
    warning: Cython/Compiler/Parsing.py:2422:0: 'p_c_base_type' redeclared
    warning: Cython/Compiler/Parsing.py:2751:0: 'p_c_declarator' redeclared
    warning: Cython/Compiler/Parsing.py:2943:0: 'p_c_arg_list' redeclared
    warning: Cython/Compiler/Parsing.py:3586:0: 'p_code' redeclared
    warning: Cython/Compiler/Parsing.py:3610:0: 'p_module' redeclared
    warning: Cython/Compiler/Parsing.py:3733:0: 'print_parse_tree' redeclared
    warning: Cython/Compiler/Pythran.py:21:0: 'is_pythran_supported_dtype' redeclared
    warning: Cython/Compiler/Pythran.py:121:0: 'to_pythran' redeclared
    warning: Cython/Compiler/Pythran.py:150:0: 'is_pythran_supported_type' redeclared
    warning: Cython/Compiler/Pythran.py:163:0: 'is_pythran_expr' redeclared
    warning: Cython/Compiler/Scanning.py:93:4: 'lookup' redeclared
    warning: Cython/Compiler/Scanning.py:400:4: 'indentation_action' redeclared
    warning: Cython/Compiler/Visitor.py:169:4: 'visit' redeclared
    warning: Cython/Compiler/Visitor.py:197:4: 'visitchildren' redeclared
    warning: Cython/Compiler/Visitor.py:247:4: 'visitchildren' redeclared
    warning: Cython/Compiler/Visitor.py:264:4: 'recurse_to_children' redeclared
    warning: Cython/Plex/Actions.py:13:4: 'same_as' redeclared
    warning: Cython/Plex/Actions.py:29:4: 'same_as' redeclared
    warning: Cython/Plex/Actions.py:50:4: 'same_as' redeclared
    warning: Cython/Plex/Actions.py:70:4: 'same_as' redeclared
    warning: Cython/Plex/Scanners.py:112:4: 'read' redeclared
    warning: Cython/StringIOTree.py:55:4: 'getvalue' redeclared
    warning: Cython/StringIOTree.py:60:4: 'copyto' redeclared
    warning: Cython/StringIOTree.py:69:4: 'commit' redeclared
    warning: Cython/StringIOTree.py:104:4: 'allmarkers' redeclared
Contributor

jdemeyer commented Nov 13, 2017

While compiling Cython itself, this gives

    warning: Cython/Compiler/Code.py:380:4: 'format_code' redeclared
    warning: Cython/Compiler/Code.py:442:4: 'none_or_sub' redeclared
    warning: Cython/Compiler/Code.py:693:4: 'new_label' redeclared
    warning: Cython/Compiler/Code.py:712:4: 'get_loop_labels' redeclared
    warning: Cython/Compiler/Code.py:717:4: 'set_loop_labels' redeclared
    warning: Cython/Compiler/Code.py:728:4: 'get_all_labels' redeclared
    warning: Cython/Compiler/Code.py:735:4: 'set_all_labels' redeclared
    warning: Cython/Compiler/Code.py:826:4: 'temps_in_use' redeclared
    warning: Cython/Compiler/Code.py:863:4: 'start_collecting_temps' redeclared
    warning: Cython/Compiler/Code.py:869:4: 'stop_collecting_temps' redeclared
    warning: Cython/Compiler/Code.py:930:4: 'get_py_string_const' redeclared
    warning: Cython/Compiler/FlowControl.py:74:4: 'empty' redeclared
    warning: Cython/Compiler/FlowControl.py:77:4: 'detach' redeclared
    warning: Cython/Compiler/FlowControl.py:86:4: 'add_child' redeclared
    warning: Cython/Compiler/FlowControl.py:94:4: 'empty' redeclared
    warning: Cython/Compiler/FlowControl.py:126:4: 'newblock' redeclared
    warning: Cython/Compiler/FlowControl.py:137:4: 'nextblock' redeclared
    warning: Cython/Compiler/FlowControl.py:151:4: 'is_tracked' redeclared
    warning: Cython/Compiler/FlowControl.py:158:4: 'is_statically_assigned' redeclared
    warning: Cython/Compiler/FlowControl.py:168:4: 'mark_position' redeclared
    warning: Cython/Compiler/FlowControl.py:173:4: 'mark_assignment' redeclared
    warning: Cython/Compiler/FlowControl.py:180:4: 'mark_argument' redeclared
    warning: Cython/Compiler/FlowControl.py:187:4: 'mark_deletion' redeclared
    warning: Cython/Compiler/FlowControl.py:194:4: 'mark_reference' redeclared
    warning: Cython/Compiler/FlowControl.py:204:4: 'normalize' redeclared
    warning: Cython/Compiler/FlowControl.py:227:4: 'initialize' redeclared
    warning: Cython/Compiler/FlowControl.py:263:4: 'map_one' redeclared
    warning: Cython/Compiler/FlowControl.py:763:4: 'mark_assignment' redeclared
    warning: Cython/Compiler/FlowControl.py:796:4: 'mark_position' redeclared
    warning: Cython/Compiler/Parsing.py:646:0: 'make_slice_node' redeclared
    warning: Cython/Compiler/Parsing.py:2422:0: 'p_c_base_type' redeclared
    warning: Cython/Compiler/Parsing.py:2751:0: 'p_c_declarator' redeclared
    warning: Cython/Compiler/Parsing.py:2943:0: 'p_c_arg_list' redeclared
    warning: Cython/Compiler/Parsing.py:3586:0: 'p_code' redeclared
    warning: Cython/Compiler/Parsing.py:3610:0: 'p_module' redeclared
    warning: Cython/Compiler/Parsing.py:3733:0: 'print_parse_tree' redeclared
    warning: Cython/Compiler/Pythran.py:21:0: 'is_pythran_supported_dtype' redeclared
    warning: Cython/Compiler/Pythran.py:121:0: 'to_pythran' redeclared
    warning: Cython/Compiler/Pythran.py:150:0: 'is_pythran_supported_type' redeclared
    warning: Cython/Compiler/Pythran.py:163:0: 'is_pythran_expr' redeclared
    warning: Cython/Compiler/Scanning.py:93:4: 'lookup' redeclared
    warning: Cython/Compiler/Scanning.py:400:4: 'indentation_action' redeclared
    warning: Cython/Compiler/Visitor.py:169:4: 'visit' redeclared
    warning: Cython/Compiler/Visitor.py:197:4: 'visitchildren' redeclared
    warning: Cython/Compiler/Visitor.py:247:4: 'visitchildren' redeclared
    warning: Cython/Compiler/Visitor.py:264:4: 'recurse_to_children' redeclared
    warning: Cython/Plex/Actions.py:13:4: 'same_as' redeclared
    warning: Cython/Plex/Actions.py:29:4: 'same_as' redeclared
    warning: Cython/Plex/Actions.py:50:4: 'same_as' redeclared
    warning: Cython/Plex/Actions.py:70:4: 'same_as' redeclared
    warning: Cython/Plex/Scanners.py:112:4: 'read' redeclared
    warning: Cython/StringIOTree.py:55:4: 'getvalue' redeclared
    warning: Cython/StringIOTree.py:60:4: 'copyto' redeclared
    warning: Cython/StringIOTree.py:69:4: 'commit' redeclared
    warning: Cython/StringIOTree.py:104:4: 'allmarkers' redeclared

scoder added a commit that referenced this issue Mar 9, 2018

Silence "redefined" warning again as it is more annoying than helpful…
… to receive it for every pxd-defined cpdef function.

See #1874.
Closes #2013.

@scoder scoder added this to the 0.28 milestone Mar 9, 2018

@scoder scoder closed this in 82b3d74 Mar 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment