I've used __declspec(selectany) many times when I needed a module-wide global var. Easier than having it once in a .h, and actually declared in a .c[pp] (or doing macro-trickery to achieve that). Just need to be careful not to include the .h in multiple modules, since each one will get its own instance of the global var, which may not be what you want.
↧