Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I default a function argument to the value of __FILE__ at the caller?

In C++, can I have a defaulted argument to a function which defaults to __PRETTY_FUNCTION___, ___FILE___, and ___LINE__ as defined at the point of the caller and not the point the defaults are supplied in a header file without using macros?

like image 200
WilliamKF Avatar asked Aug 11 '10 20:08

WilliamKF


2 Answers

You can't, but you can acheive this behavior with an additional macro. For instance:

#DEFINE THROW(e) throwException(e, __FILE__, __LINE__);

On a side note, __PRETTY_FUNCTION__ is not standard.

like image 147
KeatsPeeks Avatar answered Nov 02 '22 06:11

KeatsPeeks


No. Macros are expanded at the source line where they occur.

like image 25
Anthony Williams Avatar answered Nov 02 '22 05:11

Anthony Williams