|
Re: typeid(cls).name() problem: msg#00283telephony.openh323.general
On Mon, 21 Feb 2005 14:07:22 +0300 "Vyacheslav Frolov" <v.frolov@xxxxxxxxx> wrote: > Craig Southeren wrote: > > I've just tried it here on a dual 466 PII running RedHat 9 with no > > problems. Multiple runs gave nothing but lots of dots. > > It's OK. Can you try it on Windows? I can't put Windows on the dual processor machine I just used because I need it running Linux right now. And I do not own a machine with a hyperthreaded processor Sorry.... > > What string does the Class() function return when it fails? > > It returns garbage. > Atteched the output of rttitest.bat on w2k with HyperThreading enabled. After, some careful reading of the Microsoft documentation and a lot of reading between the lines, I think I know that the problem is. The Class member function for any PObject derived class ends looks like this: static inline const char * Class() { return PCLASSNAME(cls); } The PCLASSNAME function looks like this #define PCLASSNAME(cls) (6+typeid(cls).name()) In the MS environment, the typeid structure is not a static object. So, this code effectively returns a temporary pointer. This does not happen on Linux because we use a different method for getting the class name We could just use the same method as Linux, but I'm not keen on that because may result in wasted strings. The following patch uses templates - let me know how it goes: Index: include/ptlib/msos/ptlib/contain.h =================================================================== RCS file: /cvsroot/openh323/pwlib/include/ptlib/msos/ptlib/contain.h,v retrieving revision 1.50 diff -u -r1.50 contain.h --- include/ptlib/msos/ptlib/contain.h 30 Oct 2004 19:23:45 -0000 1.50 +++ include/ptlib/msos/ptlib/contain.h 21 Feb 2005 12:50:11 -0000 @@ -463,7 +463,16 @@ #endif #define P_HAS_TYPEINFO 1 -#define PCLASSNAME(cls) (6+typeid(cls).name()) +#define PBASECLASSNAME(cls) (6+typeid(cls).name()) + +template <class Cls> +const char * PClassNameTemplate() +{ + static std::string str(PBASECLASSNAME(Cls)); + return str.c_str(); +} + +#define PCLASSNAME(cls) PClassNameTemplate<cls>() Craig ----------------------------------------------------------------------- Craig Southeren craigs@xxxxxxxxxxxxxxxxx / craigs@xxxxxxxxxxxxx Phone: +61 243654666 ICQ: #86852844 Fax: +61 243673140 MSN: craig_southeren@xxxxxxxxxxx Mobile: +61 417231046 Jabber: craigs@xxxxxxxxxxxxxxxxxxxx Post Increment - Consulting & Services http://www.postincrement.com Vox Gratia - The Open Source VoIP portal http://www.voxgratia.org Raving Of A Strange Mind - the VoIP blog http://www.southeren.com/blog ------------------------------------------------------------------------ Check the FAQ before asking! - http://www.openh323.org/~openh323/fom.cgi The OpenH323 Project mailing list, using Mailman. To unsubscribe or change your subscription options, goto http://www.openh323.org/mailman/listinfo/openh323 Maintained by Quicknet Technologies, Inc - http://www.quicknet.net ------------------------------------------------------------------------ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Checked in "options list" to OpalMediaFormat: 00283, Robert Jongbloed |
|---|---|
| Next by Date: | RE: Recent postings to the Contribution Section on VoxGratia: 00283, Simon Horne |
| Previous by Thread: | Re: typeid(cls).name() problemi: 00283, Vyacheslav Frolov |
| Next by Thread: | Re: typeid(cls).name() problem: 00283, Vyacheslav Frolov |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |