KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to create some macros that I can use to create my own unit testing library. My header file looks like this: #ifndef _TEST_H_ #define _TEST_H_ #include <stdio.h> #include "hehe_stack.h" static hehe_stack* tests; typedef int (*testfunc)(); #define test_init() tests = hehe_stack_init(); #define test_register(test) hehe_stack_push(tests, test); #define test_info() fprintf(stdout, "running %s :: %s \n", __FILE__, __func__); #define test_run() testfunc = (int (*)()) hehe_stack_pop(tests); testfunc(); return 0; #endif In each test .c file I want to push a number of function pointers into the tests stack and then pop each function pointer out of the stack and call it. My stack pop method returns a void pointer, and the function pointer that I am pushing onto it returns an int and takes no parameters. Is my syntax incorrect? I feel like I should be able to do this.
Tags (comma-separated)
Save Edits
Cancel