RBT
RBT

Reputation: 25887

function prototype giving not found warning

I was writing a simple balanced bracket program related to data structures in C. Here is my function prototype and its corresponding method body:

int IsBracketBalanced(char[]);

int IsBracketBalanced(char bracketSequence[1000])
{
        char stack[1000];
        int isBracketBalanced = 1;

    //do something here

    return isBracketBalanced;
}

But Visual Studio is showing a green squiggle below the function prototype and shows a warning as

Function definition for 'IsBracketBalanced' not found.

Is there anything wrong in my signature because of character array parameter? I've written this code in C on visual Studio 2015 with OS being Windows 7.

Upvotes: 0

Views: 265

Answers (1)

Iharob Al Asimi
Iharob Al Asimi

Reputation: 53006

They are not exactly the same prototypes and perhaps that is confusing the code analyzer, just use

int IsBracketBalanced(char *, size_t);

instead, and of course

int IsBracketBalanced(char *bracketSequence, size_t size)

and pass the size as a parameter avoiding many problems. Many library functions like gets() eventually got rewritten to use this kind of prototype.

Since after all you cannot take any advantage of the fact the function takes an array because it's converted to a pointer anyway, there is no benefit in using char [] except perhaps readability.

Upvotes: 1

Related Questions