typedef with a member "pointer to itself"

Hello forum

I've a c progamming question:
I want to place a function pointer into a typedef with a function parameter "pointer to the typedef itself":


typedef struct pExampleStructTypdef {
  char  x;
  void  *y;
  int   z;
  int   (*pFuncPtr)(pExampleStructTypdef *, unsigned int);
}pExampleStructTypdef

It seems logical that this does not work that way. Does anybody know a solution for this? Thanks!

Parents
  • Slightly modified, it works:

    struct ExampleStruct {
      char  x;
      void  *y;
      int   z;
      int   (*pFuncPtr)(struct ExampleStruct *, unsigned int);
    };
    


    I never understood the desire to get rid of struct using typedef. If your code becomes too long with struct, the problem is with the code, not with struct.

Reply
  • Slightly modified, it works:

    struct ExampleStruct {
      char  x;
      void  *y;
      int   z;
      int   (*pFuncPtr)(struct ExampleStruct *, unsigned int);
    };
    


    I never understood the desire to get rid of struct using typedef. If your code becomes too long with struct, the problem is with the code, not with struct.

Children
More questions in this forum