![](/img/trans.png)
[英]How does a function caller use a header file to determine what to do with a compiled binary?
[英]How to determine caller function, file and line of a class constructor?
怎么样?
我试过了:
#define Some(p1, p2) _Some(p1, p2, __FILE__, __func__, __LINE__)
Some _Some(int p1, int p2, const char* file, const char* func, int line) { ... }
但:
some.hpp:16:12: error: macro "Some" requires 3 arguments, but only 1 given
~Some();
^
some.hpp:16:5: error: invalid use of destructor ‘~Some’ as a type
~Some();
^
定义一个完全独立的类,其工作是封装源代码位置。 (一个类,一个责任。)该类可以包括一些功能,可以按您喜欢的方式格式化信息。
然后定义一个具有完全唯一名称的宏,以从__LINE__
等构造类。
然后,您的Some
类构造函数只能接受一个单独的参数,它是源位置,并且调用者在每个调用中使用宏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.