Better HN
topnewbestaskshowjobs
Log inSign up

Randdalf

2 karma · joined Jan 15, 2018 (8y ago) · 1 submissions

Submissions

comment 8y ago · link · parent

I've found using a macro makes function pointers really easy. Learnt this from Handmade Hero:

  #define SOME_FUNCTION(name) void name(int Arg0, float Arg1)

  typedef SOME_FUNCTION(some_function);

  SOME_FUNCTION(SomeFunction)
  {  
  }

  struct some_functions
  {
      some_function* Foo;
      some_function* Bar; 
  };


  // Either works here.
  some_functions SomeFunctions;
  SomeFunctions.Foo = &SomeFunction;
  SomeFunctions.Bar = SomeFunction;