vendredi 11 mai 2018

ignored-qualifiers only with void* typedef

This works fine

const void* getObjHandle() {
 return (const void*)hdl;
}

But this gives ignored-qualifiers warning

typedef void* objHandle;
const objHandle getObjHandle() {
 return (const objHandle)hdl;
}

This one gives an invalid static_cast error along with the ignored-qualifiers warning

typedef void* objHandle;
const objHandle getObjHandle() {
 return static_cast<const objHandle>(hdl);
}

This works again

typedef void* objHandle;
const void* getObjHandle() {
 return static_cast<const void*>(hdl);
}

hdl is a const pointer to an object I am getting from another helper inside getObjHandle().

Aucun commentaire:

Enregistrer un commentaire