AIX Open Source

AIX Open Source

Share your experiences and connect with fellow developers to discover how to build and manage open source software for the AIX operating system

 View Only
  • 1.  Unsafe C-preprocessor defines in term.h

    Posted Fri September 11, 2020 05:26 PM
    term.h from bos.adt.include 7.2.3.16 on AIX has unsafe C-preprocessor defines.
    gcc-8.3.0-2 does not seem to fix this include file.

    $ cat a.c
    #include <curses.h>
    int a(){int lines;}
    $ gcc a.c
    In file included from /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8.3.0/include-fixed/curses.h:163,
    from a.c:1:
    a.c: In function 'a':
    a.c:2:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
    int a(){int lines;}
    ^~~~~
    a.c:2:13: error: expected expression before '->' token
    $ oslevel -s
    7200-03-03-1914
    $ lslpp -w /usr/include/term.h /usr/include/curses.h
    File Fileset Type
    ----------------------------------------------------------------------------
    /usr/include/term.h bos.adt.include File
    /usr/include/curses.h bos.adt.include File
    $ lslpp -l bos.adt.include
    Fileset Level State Description
    ----------------------------------------------------------------------------
    Path: /usr/lib/objrepos
    bos.adt.include 7.2.3.16 COMMITTED Base Application Development
    Include Files
    $ rpm -q gcc
    gcc-8.3.0-2.ppc
    $

    I discovered this while trying to compile tmux for byobu on AIX.

    ------------------------------
    Edward Davignon
    ------------------------------


  • 2.  RE: Unsafe C-preprocessor defines in term.h

    Posted Mon September 14, 2020 03:30 AM
    Hi Edward,

    I am not sure if this is problem of gcc.
    The same problem is there with other compiler on AIX. 
    The reason being curses.h includes term.h in AIX where lines is defined as macro.
    If you changed your variable lines to other name the problem is not there.

    If you choose any other OS (mac or Linux) and try the following test (replacing curses.h to term.h) same problem will appear.

    #include <term.h>
    int a(){int lines;}

    In AIX curses.h term.h is included hence the problem appears for curses.h as well.

    The other option is use open source ncurses-devel package and include header file from there. 
    Hope this helps. 




    ------------------------------
    SANKET RATHI
    ------------------------------



  • 3.  RE: Unsafe C-preprocessor defines in term.h

    Posted Mon September 14, 2020 09:42 AM

    Sanket,
    It looks like ncurses/term.h has the same problem.  I am surprised to still be finding C-preprocessor name conflicts like these in large projects and system header files.  Words like "lines" are very common.  I was not expecting library developers to still be using common words without any prefixes, especially in preprocessor defines, since preprocessor problems tend to be difficult to locate or provide meaningful error messages.

    It looks like Michael Perzl has already worked around this problem for tmux and several other problems. I will try using his patches when I have time to work on this again.

    Thanks.



    ------------------------------
    Edward Davignon
    ------------------------------