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

Gunther Piez gpiez@web.de
Mon Aug 1 20:04:00 GMT 2005


Am Montag, 1. August 2005 06:12 schrieben Sie:
> On Sun, 2005-07-31 at 19:53 -0700, Ian Lance Taylor wrote:
> > Gunther Piez <gpiez@web.de> writes:
> > > Am Montag, 1. August 2005 02:04 schrieb Ian Lance Taylor:
> > > > Gunther Piez <gpiez@web.de> writes:
> > > > > struct uniform {
> > > > >       uniform() {
> > > > >               cout << "A variable called " << __PRETTY_VARNAME__ << 
" was just
> > > > > instantinated (sp)" << endl;
> > > > >       }
> > > > > };
> >
> > ...
> >
> > > Maybe it is possible to use the debugging information somehow? At least
> > > the debugger usually knows the names of variables.
> >
> > Maybe it is possible, but nothing straightforward comes to mind.
>
> You still have the issue that you need to have all the *actual* callers
> in front of you, so you'd have to process debug info on the fly if you
> were dlopen'ing stuff like plugins.

I thought it over: "uniform" needs to be a template anyway, and knowing the 
name during compile time is sufficient. So some macro will do.

It was late and I was a bit tired yesterday, sorry for the noise :-)

Thanks for the answers.



More information about the Gcc-help mailing list