include <iostream>
  
int foo1()
{
  return(0);
}
  
int foo2(int val)
{
  return(val);
}
  
#define PROTOTYPE_BUILDER(p_return_type, p_function_name, p_parameters) \
  #p_return_type" "#p_function_name"["#p_parameters

#define foo1_prototype PROTOTYPE_BUILDER(int, foo1, ())

#define foo2_prototype PROTOTYPE_BUILDER(int, foo2, (int val))

#define HOOK_BUILDER(p_function_name, ...) \
  ({ std::cout \
      << p_function_name##_prototype \
      << " = ("#__VA_ARGS__")]" << std::endl;\
    p_function_name(__VA_ARGS__); })

#define foo1(...) HOOK_BUILDER(foo1, __VA_ARGS__)

#define foo2(...) HOOK_BUILDER(foo2, __VA_ARGS__)
  
int main()
{
  foo1();
  return(foo2(1));
}


/*
int foo1[() = ()]
int foo2[(int val) = (1)]
*/



cpp.txt · Last modified: 2022/04/16 12:22 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki