0

I get the following error when I check50 helpers.c: \ expected an exit code of 0, not standard error of "helpers.c:24:17: error: implicit declar..."

Here is the source code of helpers.c:

bool search(int value, int values[], int n)
{
    // some things before it

    int index = binarySearch(value, values, 0, n);
    return index != -1; 
}

int binarySearch(int value, int values[], int min, int max)
{
    // some things
} 

More detailed error message from sandbox:

... but received the following on standard error instead —  helpers.c:24:17: error: implicit declaration of function 'binarySearch' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
int index = binarySearch(value, values, 0, n);
            ^
1 error generated.
make: *** [find] Error 1
7
  • There's a link at the end of check50's output that has more details, but looks like you're having a function declaration that is missing.
    – kzidane
    Aug 16, 2014 at 17:50
  • @Kareem I added the prototype of binarySearch to helpers.c and it worked! But I'd rather keep it in the header file. Do you know why it might not be taking the header file into account?
    – user103853
    Aug 16, 2014 at 19:10
  • @Chris Please reduce the amount of code shown to the part relevant to the error. In this case, the lines which call binarySearch() and the function declaration, and definition for binarySearch() itself should be sufficient. Aug 16, 2014 at 19:15
  • @Chris: Regarding your header issue. 1.) Are you sure the prototype is declared in your header? 2.) Are you sure that the header is being included in the .c file (or any other files that are imported by that .c file)?
    – ZeroStatic
    Aug 16, 2014 at 19:47
  • @ZeroStatic I think the issue is that the problem set tells people to check50 the file but doesn't mention using the header file too. I.e. the say use check50 2014/x/pset3/helpers.c helpers.c instead of using check50 2014/x/pset3/helpers.c helpers.c helpers.h
    – user103853
    Aug 16, 2014 at 19:50

1 Answer 1

2

As answered by Karreem:

When using check50, the default header is used and it of course doesn't contain our declarations. So we have to keep them in the source code file in order for our solution to work on the server.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .