TObjLink::GetObject() doesn't work

Hi,

I’ve problems compiling my code. I have a TList object called “TLtrend” that contains serveral objects of my class “PVSSTrend” (kind of graph).
Now I want to access the trends via those list.

I tried to do as the “THStack::Paint()” method does. There, a TObjLink object is created, the link is extracted from the TList object and then the “TObjLink::GetObject()”-method is used to retrieve the object pointer. Then I want to use this pointer to call the trend-objects “PVSSTrend::Cancel()”-method.

Here is the interesting part of the code:

[code]TObjOptLink tempObjLink = (TObjOptLink)TLtrend->FirstLink();
PVSSTrend *tempTrend;

//cancel all trends:

while (tempObjLink) {
tempTrend = (PVSSTrend*)tempObjLink->GetObject();
tempTrend->Cancel();
tempObjLink = (TObjOptLink*)tempObjLink->Next();
}[/code]

The problem is now, that my compiler (VS.Net) claims:

[quote]error C2039: ‘GetObjectA’ : is not an element of ‘TObjOptLink’
[/quote]

I copied/pasted both the code and the error message.

So the first thing that is very interesting is, that there is no “A” in the code (where does this “GetObjectA” come from?).

The second thing is, that I changed the “GetObject()” with a “GetOption()” which is a method of TObjOptLink and everything works fine (except of the fact, that the code makes nothing meaningful anymore).

I’ve looked into the TList.h file and there I see no reason why “GetOption()” works, while “GetObject()” fails.

Of course I restarted VS.Net but that didn’t help.

Has anyone an idea what this could be?

Thanks in advance,

Tobias

Sorry, I’ve forgotten to mention, that I’m using Root version 4.00.08.

Hi Tobias,

This looks like a side-effect of one of the many Microsoft include files with many “define” statements. In particular GetObject is one of these keywords used by MS.
Look at $ROOTSYS/base/inc/Windows4Root.h
you will see a long list of such keywords that we have to undefined. GetObject is alao
referenced at the end of the file.

In your case, I would suggest to
-either #include “Windows4Root.h” in your class at the end of all includes
-or add the sattement
#undef GetObject

Rene

Thank you very much!

I added the suggested header file at the end of my includes and now it works without problems.

See you,

Tobias