Thread start functions and external C linkage (VDR starts it's threads "incorrectly")

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Klaus Schmidinger wrote:
> This would allow anybody to do
> 
>   cThread t;
>   StartThread(&t);
> 
> which I don't think would be a good thing to do.
> 
> Any ideas how to prevent this from happening?

It's perfectly okay to declare StartThread

extern "C" static void *StartThread(cThread *Thread);

within thread.c so it isn't visible outside the object thread.o. Such an 
invalid use would be caught by the (dynamic, in case of plugins) linker. 
With gcc 4.0 fulfilling the current standard the friend declaration 
isn't even a valid implicit forward declaration anymore, so a misuse of 
StartThread would even result in a compile time error then.

Greetings,
Sascha Volkenandt


[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux