python / cpython

The Python programming language
https://www.python.org
Other
63.88k stars 30.58k forks source link

#ifdef linux is incorrect; should be #ifdef __linux__ (preferred standard) #50807

Closed cd099432-c439-4196-9816-d22314ec360c closed 14 years ago

cd099432-c439-4196-9816-d22314ec360c commented 15 years ago
BPO 6558
Nosy @theller, @ngie-eign
Superseder
  • bpo-4558: ./configure --with-stdc89 to test ANSI C conformity
  • 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: ```python assignee = 'https://github.com/theller' closed_at = created_at = labels = ['extension-modules', 'ctypes', 'build'] title = '#ifdef linux is incorrect; should be #ifdef __linux__ (preferred standard)' updated_at = user = 'https://github.com/ngie-eign' ``` bugs.python.org fields: ```python activity = actor = 'terry.reedy' assignee = 'theller' closed = True closed_date = closer = 'terry.reedy' components = ['Build', 'Extension Modules', 'ctypes'] creation = creator = 'ngie' dependencies = [] files = [] hgrepos = [] issue_num = 6558 keywords = [] message_count = 3.0 messages = ['90868', '90881', '90905'] nosy_count = 3.0 nosy_names = ['theller', 'rpetrov', 'ngie'] pr_nums = [] priority = 'normal' resolution = 'out of date' stage = None status = 'closed' superseder = '4558' type = 'compile error' url = 'https://bugs.python.org/issue6558' versions = ['Python 2.6', 'Python 2.5', 'Python 2.4'] ```

    cd099432-c439-4196-9816-d22314ec360c commented 15 years ago

    The following files are looking for the linux' constant, when it fact they should be looking forlinux' (from 2.6.2 release's sources):

    Modules/_ctypes/libffi/src/mips/ffitarget.h:#ifdef linux Modules/socketmodule.c:#ifdef linux Modules/socketmodule.c:#ifdef linux

    The correct check is being made for FreeBSD (FreeBSD), for instance.

    This is a defacto standard set by gcc, as discussed here: \http://lists.debian.org/debian-devel/2001/01/msg00951.html\. You can dump out all of the available constants for any given gcc compiler via:

    [garrcoop@sjc-lds-102 ~/Python-2.6.2]$ echo "" | gcc -E -dM -c - | grep
    linux
    #define __linux 1
    #define __linux__ 1
    #define __gnu_linux__ 1
    #define linux 1

    I point this out because one of our compilers, doesn't have this definition and it's tossing up errors with the linuxaudiodev and oss modules periodically when cross-compiling, as shown below :(:

    /nobackup/shujagan/tmp/contrib/python/Modules/linuxaudiodev.c:31: error: conflicting types for 'uint32_t' /nobackup/shujagan/tmp/linkfarm/mips32/usr/include/stdint.h:52: error: previous declaration of 'uint32_t' was here

    /nobackup/shujagan/tmp/contrib/python/Modules/ossaudiodev.c:37: error: conflicting types for 'uint32_t' /nobackup/shujagan/tmp/linkfarm/mips32/usr/include/stdint.h:52: error: previous declaration of 'uint32_t' was here

    We've suggested using --without-audio, but this is a standard which should be adhered to as __linux__ is the constant of choice when looking for the Linux compiler...

    Thanks! -Garrett

    d8d5aad8-e55b-4500-a3a0-9ea982d771ff commented 15 years ago

    Did my patch python-trunk-20081209-c89.patch from bpo-4558 work for you ?

    Is the issue fixed in original libffi ?

    cd099432-c439-4196-9816-d22314ec360c commented 15 years ago

    __linux is legitimate too, so the patch looks ok, but...

    1) It won't apply cleanly against 2.4.5, most likely. 2) Why __linux instead of __linux__ ?

    gcooper@orangebox ~ $ echo "" | gcc --std=c89 -E -dM -c - | grep linux
    #define __linux 1
    #define __linux__ 1
    #define __gnu_linux__ 1

    __linux__ is the preferred nomenclature in the kernel.org sources, IIRC...