-2

in this function

    char *function(buf,salt)
    char *buf;
    char *salt;
    {
        function_body
    }

I get this error

error: argument "buf" doesn't match prototype
error: prototype declaration
argument "salt" doesn't match prototype
error: prototype declaration

This is the actual code:

    char * function(const char *, const char *);

    char *buffer = NULL;

    buffer = function(arg1, arg2);
4

2 に答える 2

2

This means you have a declaration of the function somewhere, that is different.

Also, you shouldn't be doing "K&R-style" functions, that should be written:

char * function(char* buf, char *salt);

And most likely both arguments should be const, too.

于 2013-01-21T14:44:23.767 に答える
2

You have a prototype declaration of function() somewhere and the actual function declaration does not match it. In your case the (type of the) parameters is different.

Usually, the errors show the location of the prototype. Look it up and compare it with your function declaration. The function arguments and their types must be exactly identical.

In your updated qustion you say that the prototype is defined as:

char * function(const char *, const char *);

So you also need to define your actual function as

char *function(const char *buf, const char *salt)
{
    // function_body
}

(It needs to be identical, so including the const-statements!)

于 2013-01-21T14:45:24.427 に答える