Thank you. Now i get new error.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jkbalaji
    New Member
    • Jul 2010
    • 4

    #1

    Thank you. Now i get new error.

    HI

    I get new error while running "make all". The error and the program is given below

    Program:

    Code:
    #if defined(LIBC_SCCS) && !defined(lint)
    static char sccsid[] = "@(#)bcopy.c	5.7 (Berkeley) 5/16/90";
    #endif /* LIBC_SCCS and not lint */
    
    #include <string.h>
    #include <sys/types.h>
    
    /*
     * sizeof(word) MUST BE A POWER OF TWO
     * SO THAT wmask BELOW IS ALL ONES
     */
    typedef	int word;		/* "word" used for optimal copy speed */
    
    #define	wsize	sizeof(word)
    #define	wmask	(wsize - 1)
    
    /*
     * Copy a block of memory, handling overlap.
     * This is the routine that actually implements
     * (the portable versions of) bcopy, memcpy, and memmove.
     */
    void bcopy(src0, dst0, length)
    	char *dst0;
    	char *src0;
    	register size_t length;	
    {
    	register char *dst = dst0;
    	register char *src = src0;
    	register size_t t;
    
    	if (length == 0 || dst == src)		/* nothing to do */
    		return;
    
    	/*
    	 * Macros: loop-t-times; and loop-t-times, t>0
    	 */
    #define	TLOOP(s) if (t) TLOOP1(s)
    #define	TLOOP1(s) do { s; } while (--t)
    
    	if ((unsigned long)dst < (unsigned long)src) {
    		/*
    		 * Copy forward.
    		 */
    		t = (int)src;	/* only need low bits */
    		if ((t | (int)dst) & wmask) {
    			/*
    			 * Try to align operands.  This cannot be done
    			 * unless the low bits match.
    			 */
    			if ((t ^ (int)dst) & wmask || length < wsize)
    				t = length;
    			else
    				t = wsize - (t & wmask);
    			length -= t;
    			TLOOP1(*dst++ = *src++);
    		}
    		/*
    		 * Copy whole words, then mop up any trailing bytes.
    		 */
    		t = length / wsize;
    		TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize);
    		t = length & wmask;
    		TLOOP(*dst++ = *src++);
    	} else {
    		/*
    		 * Copy backwards.  Otherwise essentially the same.
    		 * Alignment works as before, except that it takes
    		 * (t&wmask) bytes to align, not wsize-(t&wmask).
    		 */
    		src += length;
    		dst += length;
    		t = (int)src;
    		if ((t | (int)dst) & wmask) {
    			if ((t ^ (int)dst) & wmask || length <= wsize)
    				t = length;
    			else
    				t &= wmask;
    			length -= t;
    			TLOOP1(*--dst = *--src);
    		}
    		t = length / wsize;
    		TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src);
    		t = length & wmask;
    		TLOOP(*--dst = *--src);
    	}
    	return;
    }
    and i get the error:

    cc -O -DUNIX -DBSD -g -I/home/English/src/java/morph-1.5/hash -I/usr/include/X11/Xaw -c -w -o lib/bcopy.o /home/English/src/java/morph-1.5/hash/bcopy.c
    /home/English/src/java/morph-1.5/hash/bcopy.c: In function ‘bcopy’:
    /home/English/src/java/morph-1.5/hash/bcopy.c:48: error: argument ‘src0’ doesn’t match prototype
    /usr/include/bits/string3.h:90: error: prototype declaration
    /home/English/src/java/morph-1.5/hash/bcopy.c:48: error: argument ‘dst0’ doesn’t match prototype
    /usr/include/bits/string3.h:90: error: prototype declaration
    make: *** [lib/bcopy.o] Error 1

    from Line no. 44 to 51:

    The program code contains

    44. void bcopy(src0, dst0, length)
    45. char *dst0;
    46. char *src0;
    47. register size_t length;
    48. {
    49. register char *dst = dst0;
    50. register char *src = src0;
    51. register size_t t;
    Last edited by Banfa; Jul 20 '10, 01:04 PM. Reason: Added [code] ... [/code] tags
  • Oralloy
    Recognized Expert Contributor
    • Jun 2010
    • 988

    #2
    Isn't the prototype for bcopy

    Code:
    void bcopy(const void *s1, void *s2, size_t n);
    If so, you need to change the definition you're providing.

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      The definition in the OP is of the type used in pre-standardised C and given the date on line 2 that kind of matches up.

      However I agree that that might be the cause of the issue.

      Comment

      • Oralloy
        Recognized Expert Contributor
        • Jun 2010
        • 988

        #4
        Originally posted by Banfa
        The definition in the OP is of the type used in pre-standardised C and given the date on line 2 that kind of matches up.

        However I agree that that might be the cause of the issue.
        Banfa,

        Thank you, I see I need to spend more time at the feet of the masters and just listen.

        Oralloy

        Comment

        • donbock
          Recognized Expert Top Contributor
          • Mar 2008
          • 2427

          #5
          The error refers to a mismatch between a function prototype and a function definition, so there must be a prototype in one of the header files included by bcopy.c. You need to find that prototype and then resolve the mismatch be either changing the prototype to match the definition or by changing the definition to match the prototype or by replacing the prototype with an old-style function declaration.

          I am alarmed at the juxtaposition of a function prototype and an old-style function definition. The old-style definition expects the default type conversions to be applied to the arguments whenever the function is called, however if a prototype is in scope then the arguments are converted to the types in the prototype. This violation of expectations could cause the function to misinterpret the argument value it receives. I'm pretty sure this is covered somewhere in the C FAQ, but I can't seem to bring up that web site right now to find it for you.

          Comment

          Working...