Is is possible to use the name of a variable in the constructor?

Gunther Piez gpiez@web.de
Sun Jul 31 23:56:00 GMT 2005


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?



More information about the Gcc-help mailing list