Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC C compile error, void value not ignored as it ought to be

Tags:

c

gcc

I'm having trouble compiling some C code. When I compile, I'l get this error:

player.c: In function ‘login’:  
player.c:54:17: error: void value not ignored as it ought to be

This is the code for the error:

static bool login(const char *username, const char *password) {
    sp_error err = sp_session_login(g_sess, username, password, remember_me);
    printf("Signing in...\n");
    if (SP_ERROR_OK != err) {
        printf("Could not signin\n");
        return 0;
    }
    return 1;
}

Any way to bypass this kind of error?
Thanks

Edit: All sp_ functions are from libspotify

like image 847
Endre Hovde Avatar asked Sep 23 '11 21:09

Endre Hovde


3 Answers

Where is the error line exactly?

Without further information, I'm guessing it's here:

sp_error err = sp_session_login(g_sess, username, password, remember_me);

I guess sp_session_login is returning the void.

Try:

static bool login(const char *username, const char *password) {
    sp_session_login(g_sess, username, password, remember_me);
    printf("Signing in...\n");
    return 1;
}
like image 199
ldav1s Avatar answered Oct 19 '22 08:10

ldav1s


It usually means you assign the return of a void function to something, which is of course an error.

In your case, I guess the sp_session_login function is a void one, hence the error.

like image 30
Macmade Avatar answered Oct 19 '22 07:10

Macmade


I'm going to guess that sp_session_login is declared as returning void and not sp_error and there is some alternative way of determining whether it succeeded.

like image 33
moonshadow Avatar answered Oct 19 '22 07:10

moonshadow