Constructor module
nemequ opened this issue · 0 comments
nemequ commented
As mentioned in travisdowns/uarch-bench#39, it would be nice to have a macro which attempts to register a constructor function.
GLib has some code to do this already for GCC, Windows, and suncc. I'd probably want to at least a C++ version… something like (untested):
#if defined(__cplusplus)
#define PSNIP_CONSTRUCTOR(func_name) \
static class func_name#_psnip_constructor_class_ { \
public: \
func_name#_psnip_constructor_class_(int x) { \
(void) x; \
func_name(); \
} \
} func_name#_psnip_constructor_(42);
#elif ...
/* ... */
#endif