This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Is is possible to use the name of a variable in the constructor?
- From: Gunther Piez <gpiez at web dot de>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 1 Aug 2005 01:55:52 +0200
- Subject: Is is possible to use the name of a variable in the constructor?
I'm looking for something like __PRETTY_FUNCTION__ for a variable (or a
object).
It want to do
struct uniform {
uniform() {
cout << "A variable called " << __PRETTY_VARNAME__ << " was just
instantinated (sp)" << endl;
}
};
void main() {
uniform blah;
}
and get "A variable called blah was just instantinated" as program output.
This must work at runtime. Is there a identifier or macro which holds the
desired value?