Help porting app from HP-UX to Linux

Discussion in 'C Programming' started by James Egan, Mar 25, 2008.

  1. James Egan

    James Egan Guest

    I'm porting a legacy application from HP-UX to Linux. The va_start macro
    takes one argument under HP-UX, but takes two under Linux:

    va_start under HP-UX takes only one var:

    hp:/home/fred> grep va_start
    /ndata1/scratch/gcc-3.2/binutils/include/mpw/>
    #define va_start(list) list = (char *) &va_alist


    va_start under linux takes two:

    linux:/home/fred> grep -i va_start
    /usr/lib/gcc/i386-redhat-linux/4.1.1/include/stdarg.h
    #define va_start(v,l) __builtin_va_start(v,l)


    The errors I'm seeing are listed below. What would be the best way to
    handle the discrepancy in va_start between the two systems?


    >make

    lprintf.c: In function 'lprintf':
    lprintf.c:73: error: expected declaration specifiers before 'va_dcl'
    lprintf.c:89:13: error: macro "va_start" requires 2 arguments, but only
    1 given
    lprintf.c:145: error: expected '=', ',', ';', 'asm' or '__attribute__'
    before 'va_dcl'
    lprintf.c:161:13: error: macro "va_start" requires 2 arguments, but only
    1 given
    lprintf.c:218: error: expected '=', ',', ';', 'asm' or '__attribute__'
    before 'va_dcl'
    lprintf.c:234:13: error: macro "va_start" requires 2 arguments, but only
    1 given
    lprintf.c:284: error: expected '{' at end of input
    make[1]: *** [lprintf.o] Error 1
    make: *** [upper] Error 2
     
    James Egan, Mar 25, 2008
    #1
    1. Advertising

  2. James Egan said:

    > I'm porting a legacy application from HP-UX to Linux. The va_start macro
    > takes one argument under HP-UX, but takes two under Linux:


    In standard C, va_start takes two arguments, the first being the name of
    the object with type 'va_list', and the second being the name of the
    last-named parameter in the function parameter list.

    One possibility is to invoke your HP-UX compiler in conforming mode (in
    which case it must accept the two arguments, because otherwise it doesn't
    conform). If that won't wash for you, you could try conditional
    compilation, I guess.

    <snip>

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
     
    Richard Heathfield, Mar 25, 2008
    #2
    1. Advertising

  3. James Egan

    user923005 Guest

    On Mar 24, 8:24 pm, James Egan <> wrote:
    > I'm porting a legacy application from HP-UX to Linux.  The va_start macro
    > takes one argument under HP-UX, but takes two under Linux:
    >
    > va_start under HP-UX takes only one var:
    >
    > hp:/home/fred> grep va_start
    > /ndata1/scratch/gcc-3.2/binutils/include/mpw/>
    > #define va_start(list) list = (char *) &va_alist
    >
    > va_start under linux takes two:
    >
    > linux:/home/fred> grep -i va_start
    > /usr/lib/gcc/i386-redhat-linux/4.1.1/include/stdarg.h
    > #define va_start(v,l)   __builtin_va_start(v,l)
    >
    > The errors I'm seeing are listed below.  What would be the best way to
    > handle the discrepancy in va_start between the two systems?
    >
    > >make

    >
    > lprintf.c: In function 'lprintf':
    > lprintf.c:73: error: expected declaration specifiers before 'va_dcl'
    > lprintf.c:89:13: error: macro "va_start" requires 2 arguments, but only
    > 1 given
    > lprintf.c:145: error: expected '=', ',', ';', 'asm' or '__attribute__'
    > before 'va_dcl'
    > lprintf.c:161:13: error: macro "va_start" requires 2 arguments, but only
    > 1 given
    > lprintf.c:218: error: expected '=', ',', ';', 'asm' or '__attribute__'
    > before 'va_dcl'
    > lprintf.c:234:13: error: macro "va_start" requires 2 arguments, but only
    > 1 given
    > lprintf.c:284: error: expected '{' at end of input
    > make[1]: *** [lprintf.o] Error 1
    > make: *** [upper] Error 2


    To see an example of how to portably write a varadic function (for
    instance to print stuff to a log file) see the C-FAQ starting at
    section 15.4 and running over the next few items.
     
    user923005, Mar 25, 2008
    #3
  4. James Egan <> writes:
    > I'm porting a legacy application from HP-UX to Linux. The va_start macro
    > takes one argument under HP-UX, but takes two under Linux:
    >
    > va_start under HP-UX takes only one var:
    >
    > hp:/home/fred> grep va_start
    > /ndata1/scratch/gcc-3.2/binutils/include/mpw/>
    > #define va_start(list) list = (char *) &va_alist
    >
    >
    > va_start under linux takes two:
    >
    > linux:/home/fred> grep -i va_start
    > /usr/lib/gcc/i386-redhat-linux/4.1.1/include/stdarg.h
    > #define va_start(v,l) __builtin_va_start(v,l)

    [snip]

    The old pre-standard <varargs.h> interface defines a va_start macro
    that takes one argument ("man varargs" on your HP-UX system for
    details).

    The <stdarg.h> interface was introduced in the 1989 ANSI C standard,
    if not earlier. In that interface, va_start is a macro that takes
    two arguments.

    The <varargs.h> interface is still supported on some systems to
    support legacy programs, but <stdarg.h> is the right interface to use.

    If at all possible, I suggest modifying the application so it uses
    <stdarg.h>, which I'm 99.9% sure you'll find is supported on HP-UX.

    If that's not practical, you *might* be able to find an implementation
    of the old <varargs.h> for Linux, probably one built on top of
    <stdarg.h>. If that's what you need, a Linux newsgroup would be more
    likely to help you find it.

    --
    Keith Thompson (The_Other_Keith) <>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Mar 25, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pasturel Jean-Louis

    Porting JNI Windows under JNI LINUX + Wine ?

    Pasturel Jean-Louis, Feb 29, 2004, in forum: Java
    Replies:
    5
    Views:
    943
    Pasturel Jean-Louis
    Mar 3, 2004
  2. Arash Nikkar

    porting RXTX linux code to windows

    Arash Nikkar, Apr 12, 2006, in forum: Java
    Replies:
    5
    Views:
    1,712
    Martin Gregorie
    Apr 15, 2006
  3. nitin
    Replies:
    2
    Views:
    444
    Ron Natalie
    Jul 14, 2003
  4. Ryan Liu
    Replies:
    2
    Views:
    676
    Prateek R Karandikar
    Jun 12, 2004
  5. jpw
    Replies:
    1
    Views:
    384
    Gabriel Genellina
    Feb 5, 2008
Loading...

Share This Page