All pastes #385822 Raw Edit

Unnamed

public c v1 · immutable
·published 2007-03-08 03:02 UTC
rendered paste body
void somefunc(void **output); /* <- retrieves a value from a data structure;                                     consider output to be an output parameter of type void * */....later....{   struct foo *myfoo;   /* now we'll use somefunc() to restore myfoo which we stashed away earlier */   somefunc(&myfoo); /* <- pointer to incompatible type */   somefunc((void **)&myfoo) /* <- type-punned pointer breaks strict aliasing rules */   /* alternatively... */   void *v;   struct foo *myfoo;   somefunc(&v);   myfoo = v; /* ok because void * is exempt from aliasing rules;                  assume the data went: struct foo * -> void * -> struct foo *;                 however it's a pain to use 4 lines for what should be 1 line */   /* this would be OK if somefunc just returned void *; however that is not an option      for me.  What to do? */}