RE: [ROOT] _R__UNIQUE is not so unique

From: Philippe Canal (pcanal@fnal.gov)
Date: Thu Sep 26 2002 - 20:25:14 MEST


Hi Roger,

> However I didn't find a 'ClassImpTUnique' just a 'ClassImpUnique' so
> prehaps the template version is missing?

You were correct.  A templateClassImpUnique will (soon) be available in the
cvs repository.

Cheers,
Philippe.


-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Roger Moore
Sent: Wednesday, September 18, 2002 11:25 AM
To: Philippe Canal
Cc: roottalk@pcroot.cern.ch
Subject: RE: [ROOT] _R__UNIQUE is not so unique


On Tue, 17 Sep 2002, Philippe Canal wrote:

> Does anybody know how we could implement this differently?  (It has to be
a
> CPP macro since the whole purpose is to acquire the __FILE__ and __LINE__
in
> the implementation file.

Why not pass the class name as part of the static variable name? It is
far less likely that there will be two indentically named classes
(in different namespaces) which have ClassImpT declared on the same line.
The class name is already passed as an argument to ClassImpT so it should
not be hard to change the code to create a:

	R__dummyholderMyClass123

symbol name. In fact I believe that all you would need is the following
patch (I haven't actually tried this so there may be a bug in it...)

============================================================================
--- Rtypes.h    Thu Aug 15 20:57:32 2002
+++ /home/rwmoore/Rtypes.h      Wed Sep 18 11:20:33 2002
@@ -285,7 +285,7 @@
 #define templateClassImp(name)
 #else
 #define templateClassImp(name) \
-static TNamed *_R__UNIQUE_(R__dummyholder) = \
+static TNamed *_R__UNIQUE_(_R__JOIN(R__dummyholder,name)) = \
                 ROOT::RegisterClassTemplate(_QUOTE_(name), __FILE__,
__LINE__);
 #endif

============================================================================

This should simply add the given name argument onto the R__dummyholder.
Alternatively you could just do:

#define ClassImpT(name,Tmpl) ClassImpTUnique(name,Tmpl,name)

However I didn't find a 'ClassImpTUnique' just a 'ClassImpUnique' so
prehaps the template version is missing?

hope this helps,

Roger



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:11 MET