Thread: Whats this error?

  1. #1
    Registered User
    Join Date
    Feb 2016
    Location
    Concord, NH
    Posts
    6

    Whats this error?

    Non C programmer here.

    What's this error mean?

    Thank you.


    xdr.c: In function 'xdr_u_char':
    xdr.c:262:8: error: argument 'cp' doesn't match prototype
    char *cp;
    ^
    In file included from xdr.c:49:0:
    rpc/xdr.h:278:15: error: prototype declaration
    extern bool_t xdr_u_char(XDR *, u_char *);
    ^
    xdr.c: In function 'xdr_union':
    xdr.c:467:22: error: argument 'choices' doesn't match prototype
    struct xdr_discrim *choices; /* [value, xdr proc] for each arm */
    ^
    In file included from xdr.c:49:0:
    rpc/xdr.h:276:15: error: prototype declaration
    extern bool_t xdr_union(XDR *, enum_t *, char *, const struct xdr_discrim *, xdrproc_t);
    ^

  2. #2
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    689
    Since we can't see the source, can't see how it was compiled, or compile it ourselves, and don't know what compiler, or O/S you are using, HOW can we possibly answer this question?

    Please post the source, preferably a small sample program that demonstrates the errors that you are seeing.

    Thank you.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    3,725
    My guess is u_char is NOT the same as char; therefore it says they are NOT the same.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  4. #4
    Registered User
    Join Date
    Feb 2016
    Location
    Concord, NH
    Posts
    6
    I'm on Windows7, GCC V5.2, MinGW Msys V1., and trying to compile WinPortableXDR-4.9.1.

    which is here WinPortableXDR in Launchpad

    The code is here

    Code:
    /* @(#)xdr.c    2.1 88/07/29 4.0 RPCSRC */
    /*
     * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
     * unrestricted use provided that this legend is included on all tape
     * media and as a part of the software program in whole or part.  Users
     * may copy or modify Sun RPC without charge, but are not authorized
     * to license or distribute it to anyone else except as part of a product or
     * program developed by the user.
     * 
     * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
     * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
     * 
     * Sun RPC is provided with no support and without any obligation on the
     * part of Sun Microsystems, Inc. to assist in its use, correction,
     * modification or enhancement.
     * 
     * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
     * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
     * OR ANY PART THEREOF.
     * 
     * In no event will Sun Microsystems, Inc. be liable for any lost revenue
     * or profits or other special, indirect and consequential damages, even if
     * Sun has been advised of the possibility of such damages.
     * 
     * Sun Microsystems, Inc.
     * 2550 Garcia Avenue
     * Mountain View, California  94043
     */
    #if !defined(lint) && defined(SCCSIDS)
    static char sccsid[] = "@(#)xdr.c 1.35 87/08/12";
    #endif
    
    /*
     * xdr.c, Generic XDR routines implementation.
     *
     * Copyright (C) 1986, Sun Microsystems, Inc.
     *
     * These are the "generic" xdr routines used to serialize and de-serialize
     * most common data items.  See xdr.h for more info on the interface to
     * xdr.
     */
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    #include "rpc/types.h" 
    #include "rpc/xdr.h" 
    
    /* #include "C:\MinGW\include\rpc.h" ! calls _ansi.h */
    
    
    
    /* #include "H:\RIH5342\xdr\github\types.h" */
    /* #include "H:\RIH5342\xdr\github\xdr.h" */
    
    /*
     * constants specific to the xdr "protocol"
     */
    #define XDR_FALSE    ((long) 0)
    #define XDR_TRUE    ((long) 1)
    #define LASTUNSIGNED    ((u_int) 0-1)
    
    /*
     * for unit alignment
     */
    static char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 };
    
    /*
     * Free a data structure using XDR
     * Not a filter, but a convenient utility nonetheless
     */
    void
    xdr_free(proc, objp)
        xdrproc_t proc;
        char *objp;
    {
        XDR x;
        
        x.x_op = XDR_FREE;
        (*proc)(&x, objp);
    }
    
    /*
     * XDR nothing
     */
    bool_t
    xdr_void(/* xdrs, addr */)
        /* XDR *xdrs; */
        /* caddr_t addr; */
    {
    
        return (TRUE);
    }
    
    /*
     * XDR integers
     */
    bool_t
    xdr_int(xdrs, ip)
        XDR *xdrs;
        int *ip;
    {
    #ifdef lint
        (void) (xdr_short(xdrs, (short *)ip));
        return (xdr_long(xdrs, (long *)ip));
    #else
        if (sizeof (int) == sizeof (long)) {
            return (xdr_long(xdrs, (long *)ip));
        } else {
            return (xdr_short(xdrs, (short *)ip));
        }
    #endif
    }
    
    /*
     * XDR unsigned integers
     */
    bool_t
    xdr_u_int(xdrs, up)
        XDR *xdrs;
        u_int *up;
    {
    
    #ifdef lint
        (void) (xdr_short(xdrs, (short *)up));
        return (xdr_u_long(xdrs, (u_long *)up));
    #else
        if (sizeof (u_int) == sizeof (u_long)) {
            return (xdr_u_long(xdrs, (u_long *)up));
        } else {
            return (xdr_short(xdrs, (short *)up));
        }
    #endif
    }
    
    /*
     * XDR long integers
     * same as xdr_u_long - open coded to save a proc call!
     */
    bool_t
    xdr_long(xdrs, lp)
        register XDR *xdrs;
        long *lp;
    {
    
        if (xdrs->x_op == XDR_ENCODE)
            return (XDR_PUTLONG(xdrs, lp));
    
        if (xdrs->x_op == XDR_DECODE)
            return (XDR_GETLONG(xdrs, lp));
    
        if (xdrs->x_op == XDR_FREE)
            return (TRUE);
    
        return (FALSE);
    }
    
    /*
     * XDR unsigned long integers
     * same as xdr_long - open coded to save a proc call!
     */
    bool_t
    xdr_u_long(xdrs, ulp)
        register XDR *xdrs;
        u_long *ulp;
    {
    
        if (xdrs->x_op == XDR_DECODE)
            return (XDR_GETLONG(xdrs, (long *)ulp));
        if (xdrs->x_op == XDR_ENCODE)
            return (XDR_PUTLONG(xdrs, (long *)ulp));
        if (xdrs->x_op == XDR_FREE)
            return (TRUE);
        return (FALSE);
    }
    
    /*
     * XDR short integers
     */
    bool_t
    xdr_short(xdrs, sp)
        register XDR *xdrs;
        short *sp;
    {
        long l;
    
        switch (xdrs->x_op) {
    
        case XDR_ENCODE:
            l = (long) *sp;
            return (XDR_PUTLONG(xdrs, &l));
    
        case XDR_DECODE:
            if (!XDR_GETLONG(xdrs, &l)) {
                return (FALSE);
            }
            *sp = (short) l;
            return (TRUE);
    
        case XDR_FREE:
            return (TRUE);
        }
        return (FALSE);
    }
    
    /*
     * XDR unsigned short integers
     */
    bool_t
    xdr_u_short(xdrs, usp)
        register XDR *xdrs;
        u_short *usp;
    {
        u_long l;
    
        switch (xdrs->x_op) {
    
        case XDR_ENCODE:
            l = (u_long) *usp;
            return (XDR_PUTLONG(xdrs, &l));
    
        case XDR_DECODE:
            if (!XDR_GETLONG(xdrs, &l)) {
                return (FALSE);
            }
            *usp = (u_short) l;
            return (TRUE);
    
        case XDR_FREE:
            return (TRUE);
        }
        return (FALSE);
    }
    
    
    /*
     * XDR a char
     */
    bool_t
    xdr_char(xdrs, cp)
        XDR *xdrs;
        char *cp;
    {
        int i;
    
        i = (*cp);
        if (!xdr_int(xdrs, &i)) {
            return (FALSE);
        }
        *cp = i;
        return (TRUE);
    }
    
    /*
     * XDR an unsigned char
     */
    bool_t
    xdr_u_char(xdrs, cp)
        XDR *xdrs;
        char *cp;
    {
        u_int u;
    
        u = (*cp);
        if (!xdr_u_int(xdrs, &u)) {
            return (FALSE);
        }
        *cp = u;
        return (TRUE);
    }

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,390
    Compare:
    Code:
    extern bool_t xdr_u_char(XDR *, u_char *);
    with:
    Code:
    bool_t
    xdr_u_char(xdrs, cp)
        XDR *xdrs;
        char *cp;
    {
    Actually, the latter uses an obsolete method of parameter list declaration. It might be clearer with the modern version:
    Code:
    bool_t xdr_u_char(XDR *xdrs, char *cp)
    {
    As stahta01 surmised in post #3, you have a conflict here where the prototype says that the second parameter is of type u_char*, but the definition says that it is of type char*, with u_char and char being essentially different types, and my guess (since you did not provide the code for that) is that at the function call, a char* was provided as the corresponding argument, since the error says "argument 'cp' doesn't match prototype". The comment for xdr_u_char says "XDR an unsigned char", and we see that there is xdr_char with the same parameters, so I believe that we are looking at a bug in the definition, i.e., it should have been:
    Code:
    bool_t xdr_u_char(XDR *xdrs, u_char *cp)
    {
    Of course, this means that you also need to change your function call to pass a u_char* as the argument, or if you must pass a char*, then xdr_char should be called instead.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,687
    Why or how have you got source code from Sun Microsystems? Is it not
    copyrighted anymore? I know Oracle own it now.
    Double Helix STL

  7. #7
    Registered User
    Join Date
    Feb 2016
    Location
    Concord, NH
    Posts
    6
    [laserlight]: a very clear and useful answer, thank you.

    I'm compiling a SW project, XDR is one of the required libraries.

    [swgh]: XDR is part of glibc, the source code is available from many sites.
    Each one requires a consistent family of headers, which is problematic for a windows project.

  8. #8
    Registered User
    Join Date
    Feb 2016
    Location
    Concord, NH
    Posts
    6
    The next error ...


    xdr.c: In function 'xdr_union':
    xdr.c:467:22: error: argument 'choices' doesn't match prototype
    struct xdr_discrim *choices; /* [value, xdr proc] for each arm */
    ^
    In file included from xdr.c:49:0:
    rpc/xdr.h:276:15: error: prototype declaration
    extern bool_t xdr_union(XDR *, enum_t *, char *, const struct xdr_discrim *, xdrproc_t);
    ^
    The next code fragment ...


    Code:
    /*
     * XDR a descriminated union
     * Support routine for discriminated unions.
     * You create an array of xdrdiscrim structures, terminated with
     * an entry with a null procedure pointer.  The routine gets
     * the discriminant value and then searches the array of xdrdiscrims
     * looking for that value.  It calls the procedure given in the xdrdiscrim
     * to handle the discriminant.  If there is no specific routine a default
     * routine may be called.
     * If there is no specific or default routine an error is returned.
     */
    bool_t
    xdr_union(xdrs, dscmp, unp, choices, dfault)
        register XDR *xdrs;
        enum_t *dscmp;        /* enum to decide which arm to work on */
        char *unp;        /* the union itself */
        struct xdr_discrim *choices;    /* [value, xdr proc] for each arm */
        xdrproc_t dfault;    /* default xdr routine */
    {
        register enum_t dscm;
    
        /*
         * we deal with the discriminator;  it's an enum
         */
        if (! xdr_enum(xdrs, dscmp)) {
            return (FALSE);
        }
        dscm = *dscmp;
    
        /*
         * search choices for a value that matches the discriminator.
         * if we find one, execute the xdr routine for that value.
         */
        for (; choices->proc != NULL_xdrproc_t; choices++) {
            if (choices->value == dscm)
                return ((*(choices->proc))(xdrs, unp, LASTUNSIGNED));
        }
    
        /*
         * no match - execute the default xdr routine if there is one
         */
        return ((dfault == NULL_xdrproc_t) ? FALSE :
            (*dfault)(xdrs, unp, LASTUNSIGNED));
    }

  9. #9
    Registered User
    Join Date
    May 2009
    Posts
    3,725
    I strongly suggest getting both "xdr.c" and "rpc/xdr.h" from the same source.

    Either that you are going to have to learn C programming. (You likely will still need to learn C programming even if you get them from the same source.)

    I suggest if you can NOT get both from the same source; that you first convert the "xdr.c" file into standard C from the K&R C code where function declarations(Prototypes)/definitions currently used. As hinted by laserlight.
    I found this code glibc: sunrpc/xdr.c | Fossies which looks closer to what I think is needed.

    Your current problem is likely missing constant keyword "const".

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. whats my error? tetris movement
    By Alexius Lim in forum C Programming
    Replies: 2
    Last Post: 05-15-2013, 04:00 AM
  2. Replies: 13
    Last Post: 08-03-2011, 10:18 AM
  3. dev c++......WHATS THE ERROR..PLZ HELP
    By nikita in forum C++ Programming
    Replies: 7
    Last Post: 12-29-2009, 02:42 PM
  4. Lvalue error? Whats that?
    By Iconate in forum C Programming
    Replies: 28
    Last Post: 03-25-2008, 05:33 AM
  5. whats this error??? help
    By sami in forum C++ Programming
    Replies: 4
    Last Post: 10-13-2001, 08:17 AM

Tags for this Thread