text: Q:
  
  Call functions with unknown names
  
  As a little personal project I am doing a small, very simple, test-framework in C. 
  The problem I am facing, is that I want to be able to register test cases (i.e. functions with ASSERTS of some kinds in them) automatically when a user writes them, and then run them in my predefined main function. 
  So from the user side, I only want to have to do
  TEST_CASE("TestName1")
  {
      // Testing stuff here
  }
  
  TEST_CASE("TestName2")
  {
       // Testing more stuff here
  }
  
  and the rest should be covered.
  At the moment the define only looks like
  #define TEST_CASE(name) int name()
  
  and the question is therefor if it is possible to somewhat "remember" these functions so I can call them in the main function.
  EDIT:
  So the point is that the user should include a "test-framework.h" which defines a predefined main() function which runs all the tests that the user specified with TEST_CASEs. That meaning it should look something like this:
  User defined file:
  // File where tests are defined
  #include "framework.h"
  
  TEST_CASE("TestCase1")
  {
      // Test stuff
  }
  
  TEST_CASE("TestCase2")
  {
      // Test more stuff
  }
  
  And in the framework file:
  // framework.h
  
  #define TEST_CASE(name) int name()
  
  int main()
  {
      // Here run all TEST_CASEs there is
  }
  
  That meaning, I do not know the names of the TEST_CASES in my main().
  
  A:
  
  You can't really do it exactly the way you want, but if you're ok with the user having to do a bit more work, like eg. :
  TEST_CASE(TestName1) {
      return 42;
  }
  
  TEST_CASE(TestName2) {
      return 0;
  }
  
  ALL_TEST_CASES {
      REGISTER_TEST_CASE(TestName1);
      REGISTER_TEST_CASE(TestName2);
  }
  
  then your framework could have code like this (using function pointers to register the test cases) :
  typedef struct TestCase {
      const char* name;
      int (*fptr)();
  } TestCase;
  
  TestCase testCases[10];
  size_t testCnt = 0;
  
  #define ALL_TEST_CASES void registerTestCases()
  #define TEST_CASE(NAME) int NAME()
  #define REGISTER_TEST_CASE(NAME) do { testCases[testCnt].name = #NAME; testCases[testCnt++].fptr = &NAME; } while (0)
  
  and the main :
  int main(void) {
      registerTestCases();
  
      size_t i;
      for (i = 0; i < testCnt; ++i) {
          fprintf(stdout, "Test %s : %d\n", testCases[i].name, testCases[i].fptr());
      }
  
      return 0;
  }
  
  Obviously this needs to be made more robust etc. - it should just serve as a proof of concept.
  
  