Farzan Majdani Farzan Majdani - 1 month ago 10
C Question

invalid use of void expression when passing a function as parameter

I have a function called

GLOBAL char* GET_Enum(REC_NO recNo )
{
.....
}


also I have a function which take this function as an input like this

static void Dropdowns( char* param ,
char* title,
char* (*enumFunction)(REC_NO),
int maxRecNo)
{
.....
}


Then I call that function like this

Dropdowns("test", "Location", GET_Enum, 3);


But it doesn't compile and gives me the error below:

error: invalid use of void expression


I have looked at this issues Link1 and Link2 which are relevant but I still can't see what I am doing wrong? any idea? Thanks

Answer

Seems You have error in other place, or give us wrong additional information.

Code (with explanation) compile very well, MSVC 2015

#include "stdafx.h"

static char* GET_Enum(char  recNo[14] )
{
    return NULL;
}

static void Dropdowns(char* param,
    char* title,
    char* (*enumFunction)(char[14]),
    int maxRecNo)
{
}
int main()
{
    Dropdowns("test", "Location", GET_Enum, 3);
    return 0;
}

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Comments