Is there a difference in performance for casting to and from a void *
instead of casting to some base struct? This is in part to achieve a semi-dynamic typing system.
Here is my code:
#include "stdlib.h"
typedef struct
{
unsigned char type;
} Dyn;
typedef struct
{
unsigned char type;
int number;
} Num;
typedef struct
{
unsigned char type;
char letter;
} Lett;
int main(void) {
Num* n = (Num *)malloc(sizeof(Num));
void* hold = n; // to void * casting
Num* n_g = (Num *)hold;
Dyn* dhold = (Dyn *)n; // to base struct casting
Num* n_d = (Num *)dhold;
return 0;
}
So in terms of pointers to structs, is there any performance difference between using void *
or a base type struct?