So I just stumbled across a very unlikely, but still possible, thing to watch out for when making plugins for REALbasic. On Windows, some compilers (like Visual Studio) support special functionality for thread local storage. Instead of requiring you to use the Tls APIs, Visual Studio exposes a special __declspec for TLS:
__declspec( thread ) int someVar;
This would declare a 4-byte piece of thread local storage (so each thread would get its own copy of someVar, even though it's global in scope).
REALbasic plugins cannot make use of this because it takes special magic from the system loader to make it work. The REALbasic plugin loader doesn't do the necessary fiddling with the TEB to make this magic work, and I highly doubt it ever will (just due to the fragility of it alone). If you really need thread local storage, use the Tls APIs provided by Microsoft like TlsAlloc, et al. However, TLS is so rarely used that 99% of plugin devs out there can simply ignore this gotcha.
If you want to learn about how TLS works, I'd recommend this series of blog postings by Ken "Skywing" Johnson.
Leave a comment