Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructor module #18

Open
nemequ opened this issue Mar 15, 2018 · 0 comments
Open

Constructor module #18

nemequ opened this issue Mar 15, 2018 · 0 comments

Comments

@nemequ
Copy link
Owner

nemequ commented Mar 15, 2018

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant