View Full Version : Help: returning a TBuf does not work!


animage
23-11-2004, 08:56 AM
I have a method in which I define a TBuf<20> (stack-based). I want to return exactly this Tbuf, as an automatic, stack-based copy. Simple and plain... but it doesn't work! It seems that my data in the descriptor gets mixed up somehow, you can see some things while debugging, but it's not an identical copy!
I did it like this way:

TDes foo()
{
TBuf<20> output;
//... output gets properly (!) filled
return output;
}

called like this:
TBuf<20> input;
input = foo();

What's wrong? :-( I've tried almost everything it seems to me!

Rym
04-01-2005, 08:30 PM
Hi!

You cannot simply return a descriptor, you can only return a reference to descriptor. Modify your function as follows:

TDes & foo()

Leave the rest without change.