Ask HN: Work Around for passing C Pointers
hey, I'm wondering if there's a way to get the ptr to a caller of a function from within the called function in c (without passing in the ptr as an arg). Basically, I've been experimenting on how to do oop style programming in c, so any ideas or suggestions here are more than welcome :) Here's an example to help clear things up.<p><pre><code>  struct Person {
   char name[32];
   char * (*setName)( struct Person *, const char *); 
  };

  char *setName( struct Person *self, const char *name) {
    strcpy(self-&#62;name, name );
  }
 
  int main(void) {
    struct Person *p = (struct Person *)malloc(sizeof(struct Person));
    p-&#62;setName = &#38;setName;

    // here I'd really like to not have to pass the ptr 'p'
    // is there any way to do this?
    p-&#62;setName(p, "John Doe");
  }
</code></pre>
Thanks in advance!