Reputation: 51
I am getting the following warning:
warning: declaration of `lr_searchReplace' does not match previous declaration at vuser_init.c (941)
code is as below:-
Note: I have declared char *abc;
in global.
vuser_init()
{
abc = lr_eval_string("{c_Topic1Name}");
lr_searchReplace(abc,"c_newtopic1name",'_','-');
lr_output_message("New string is :- %s",lr_eval_string("{c_newtopic1name}"));
return(0);
}
void lr_searchReplace(char* inputStr, char* outputStr, char lookupChar, char repChar)
{
char *ptr =inputStr;
char xchar;
int len=0;
int i=0;
lr_output_message("%s",inputStr);
xchar = *ptr;//Copy initial
len=strlen(inputStr);
while (len>0)
{
len--;
xchar = *ptr;
if(xchar==lookupChar)
{
inputStr[i]= repChar;
}
ptr++;
i++;
}
lr_save_string(inputStr,outputStr);
lr_output_message("%s",inputStr);
}
Upvotes: 1
Views: 1282
Reputation: 4752
You are probably calling lr_searchReplace()
before you have provided a declaration of the function. In old versions of the C standard (C89), this was allowed and the function would be given an implicit declaration of:
int lr_searchReplace();
That is, a function taking an unknown number of non-variadic parameters, and returning int
. This clearly contradicts the actual declaration which comes later.
In more recent versions of the standard (C99/C11), the compiler is required to produce a diagnostic message if you try to call a function that has not been declared.
You should change your code so that the function definition appears before the function call, or provide a function declaration before the function call. Eg:
/* Declaration - Note semi-colon at the end of the declaration */
void lr_searchReplace(char* inputStr, char* outputStr, char lookupChar, char repChar);
/* Function call */
vuser_init()
{
lr_searchReplace(abc,"c_newtopic1name",'_','-');
}
/* Function definition - including function body */
void lr_searchReplace(char* inputStr, char* outputStr, char lookupChar, char repChar)
{
...
}
Upvotes: 2
Reputation: 39
lr_searchReplace(abc,"c_newtopic1name",'_','-');
void lr_searchReplace(char* inputStr, char* outputStr, char lookupChar, char repChar
You are passing a const pointer to outputstr.
Upvotes: 0