samedi 4 décembre 2021

Cast a void pointer to another type based on an input parameter

I am trying to create a variable of type A or B based on an input parameter and assign a casted void pointer to it.

void set_info_param(void* info, bool req)
{
    ...
    if (req)
        struct info *capa_info = (struct info *) info;
    else
        struct info_old *capa_info = (struct info_old *) info;
    ... [Use capa_info]
}

When I try to compile it I get the following error:

expected expression before 'struct'

Aucun commentaire:

Enregistrer un commentaire