[fpc-pascal] Re: How to initialize thread vars?

"Vinzent Höfler" JeLlyFish.software at gmx.net
Thu Sep 4 14:57:48 CEST 2008


Hi,

> I think that thread variables are automatically initialized to zero. So
> you just need to use them in such a way that zero is the desired start
> value.

Hmm, yes. I just checked the sourcecode and indeed, for Win32 and Unix at least the threadvars are indeed initialized to zero. That would fit nicely here. ;)

If any of the developers could confirm, whether this is guaranteed semantics or was just a sane choice by the implementor? Because the documentation reads quite a bit differently:

<http://www.freepascal.org/docs-html/ref/refse22.html#x53-590004.4> states:

"Note that the copy is made with the original value of the variable, not with the value of the variable at the time the thread is started."

Which doesn't make too much sense to me considering that I can't initialize thread vars at all (compiler complains: 'Cannot initialize variables declared as threadvar'). So what would this "original value" be (besides the obvious zero - which is the default value for all global variables)?


Vinzent.
-- 
GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit Pastry Passion!
http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196



More information about the fpc-pascal mailing list